Openshift action_hook is not executable - node.js

I have recently create my first Openshift node application and currently trying to get the build scripts working when I push to the server via git (using action_hook).
I am writing the application using PhpStorm on Windows and have had no problem pushing files to the server.
I have create the following file: .openshift/action_hook/build which contains the following:
#!/bin/bash
webpack --config $OPENSHIFT_DATA_DIR/webpack.config.js
When I push to the server using git, I get the following error:
NOTE: The .openshift/action_hooks/build hook is not executable, to make it executable:
On Windows run: git update-index --chmod=+x .openshift/action_hooks/build
On Linux/OSX run: chmod +x .openshift/action_hooks/build
I have tried the windows command above but when running git ls-tree HEAD to check the file permission, I can see they have not changed:
100644 blob 1b82131d8b9e9c63b765ef328ecbbfb54f0c70aa build
Has anybody managed to get this working on windows?
Thanks a lot

Related

Git command run with child_process.spawn is unable to find git-lfs subcommand

I've got an electron app (Electron v17.4.10) running on macOS Monterey (v12.5) and on startup it attempts to perform the command git lfs install. It does so by using the Node child_process package's spawn command to invoke a direct call to a standalone git executable.
When the electron app is installed, it provides its own version of git that isn't added to the PATH to prevent interfering with any git versions that may already be installed. The standalone version of git (v2.33.0) has the folder structure shown in the image below and the git-lfs binary (v3.2.0) is contained within /PortableGit/git/libexec/git-core/
Standalone Git Directory Structure
The full command executed is:
"/Applications/MyApp/Utilities/PortableGit/bin/git" lfs install
And the output is:
git: 'lfs' is not a git command. See 'git --help'.
The most similar command is
log
How can I get the standalone installation of git to recognize the subcommand lfs without placing it on the PATH? Is having a self-contained git package like I've described even possible? Or should I abandon the approach and ensure git is installed properly on the target machine?
The answer to this problem is that Electron's process.env is different from the target system's env. So while Git will look for submodules on the PATH, the PATH used in the Terminal will be different from the PATH used by the child process.
Appending a ':' followed by the path to where the git-lfs binary is stored to process.env.PATH will allow the standalone git installation to properly identify git-lfs subcommands.
I.E.
process.env.PATH = process.env.PATH + ":" + "path/to/git/lfs"

Jenkins-Publish over SSH plugin: Getting error on npm

I am trying to setup CI/CD pipeline for my node.js application with Jenkins.
What I am trying to do is login to my application server through jenkins and execute the commands on the server with the help of publish over ssh plugin
(https://wiki.jenkins.io/display/JENKINS/Publish+Over+SSH+Plugin).
I've selected the Send Files or Execute commands over SSH option and added the following commands in Exec command section.
cd <project-folder> && git pull origin master && npm install
I am getting an error like npm not found but I try to directly on the server there is no error.
So I believe there's is a permission issue on jenkins but i can't find the solution
Yes, you identified the issue correctly ... Its permission issue ..
I assume you have already added the root login details at "SSH remote hosts" in the "configure system" section of the jenkins.
First pull the GIT repo to the jenkins workspace via web hook settings in github. Hope you have succeeded in this step also
In "Build Environment" select "Execute shell script on remote host using ssh" then use the following
cd <project-folder> (Ex: cd /var/lib/jenkins/workspace/<project-folder>)
npm install
NOTE: you should give the complete server path in the server to avoid permission .. If you are working with localhost then it may work and other very important when you use "Execute shell script on remote host using ssh" you should access via root user only NOT with the cpanel account login.. This will avoid permissions issue.
Once the NPM is install, check the console log for "success" Then do the other commands and suggest to remove the "npm install" as installation multiple times will increase the application compiling time..

Pulling a git repo from a startup script on google cloud compute engine

To show my team how the app that I am building is progressing, I created a small dev server on google cloud compute engine. This server is usually switched off to save cost and only is switched on when we are working together. I am developing and pushing to a git repo when the server is not on. When I start the server, the latest changes should be pulled, the node packages installed and the node server should be started. To do this I have created the following startup script:
#! /bin/bash
cd /to/my/server/folder
git pull
sudo npm install --no-progress
nohup node src/ &
I have created an ssh key and added that as a read only deploy key in my gitlab account on this particular repo. The script is tested on the server and works totally fine. Now the fun part.
When the script is run as a startup script (https://cloud.google.com/compute/docs/startupscript) it doesn't work. The error:
permission denied (public key)
fatal: could not read from repo make sure it exists.
I tried these fixes:
Getting permission denied (public key) on gitlab. The problem being that they can not pull git repos in general. In my case it works fine from command line, it works fine from shell script, but it just doesn't work from startup script.
I also tried a whole bunch of other stuff on the whole spectrum from 'could be it' to 'a wild guess'. Clearly there is something I am missing here. Could anyone help me out?
Finally found the answer here: https://superuser.com/a/868699/852795. Apparently something goes wrong with the SSH keys that are used in a google startup script. The solution is to explicitly tell git what key to use. Like this: GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa" git pull.

Execute command after deploy AWS Beanstalk

I have problem with execute command after deploy, i have some node.js project and script, this script use some bin from node_modules, if i write my command for script in .ebextensions/.config he execute before npm install and return error ("node_modules/.bin/some": No such file or directory). How i can execute command after deploy. Thanks.
I found the following solution
I add to beanstalk config next command:
commands:
create_post_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/some_job.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
cd /var/app/current
export PATH=$PATH:$(ls -td /opt/elasticbeanstalk/node-install/node-* | head -1)/bin
npm run some_script
This commands create(if not exist) folder for post-hooks scripts and adds bash script. Scripts in this folders execute only after npm install, this very important for my problem.
Thanks to this guy http://junkheap.net/blog/2013/05/20/elastic-beanstalk-post-deployment-scripts/
create a file called .ebextensions/post_actions.config:
container_commands:
<name of container_command>:
command: "<command to run>"
this will be executed after the code was extracted, but before it was launched.
A better approach would be to go with the aws platform hooks. Where you can define the postdeploy hooks AWS Patform Hooks
In that inside the project root directory you can add .platform/hooks/postdeploy/
Insdie this path you can create xxx-postdeploy-script.sh. Files here run after the Elastic Beanstalk platform engine deploys the application and proxy server.This is the last deployment workflow step
If you read the AWS ebextensions documentation they mention the execution, specifically where they mention that all commands are executed before the application version is deployed.
"You can use the container_commands key to execute commands for your
container. The commands in container_commands are processed in
alphabetical order by name. They run after the application and web
server have been set up and the application version file has been
extracted, but before the application version is deployed."
If you deploy it for a second time it should work; this is because your application is already unpacked. This however is not a working solution because every new instance that is spawned will error.

How to install rabbitmq and erlang on centOS without root user?

Can anyone help me with installation?
I have install virtualEnv and trying to install both of these. but not sure it is correct or not.
I know this is an old version, but it worked for me on a different Linux build (Mate OS). Follow the steps in this blog post which I have simplified below.
Download the below
ERLANG from OTP R16B03-1 Source File
RabbitMQ from RabbitMQ Server.tar.gz
Installing Erlang
Extract the ERLANG file
cd to source folder
run $ configure
run $ make
Open Makefile and change /Users/deepkrish/Application/erlang to a suitable directory
The line you are looking for is the below:
# prefix from configure, default is /usr/local (must be an absolute path) prefix = /Users/deepkrish/Application/erlang
Run $ make install
Once Erlang is installed non root user add the erlang/bin to PATH in .bash_profile like below:
export ERLANG=”/Users/deepkrish/Application/erlang/bin”
export PATH=${ERLANG}:${PATH}
Now execute the profile by running `$ source .bash_profile” or log off and login again.
Check $ erl -version This should give you the below:
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.10.4
Installing RabbitMQ
Untar the RabbitMQ.tar file and $ cd to the extracted folder
run $ make
2. This should create a scripts folder. Now change into that. $ cd scripts
Now change the below in the rabbitmq-defaults file. This will change where we run and log rabbitMQ. You can change it to the folder you want to run RabbitMQ from as below
### next line potentially updated in package install steps SYS_PREFIX=~/Application/RabbitMQ
Save and close the file
Now create a directory mkdir -p ../etc/rabbitmq Note that if you don't have access to the /etc directory you can also change it to somewhere else.
./rabbitmq-plugins enable rabbitmq_management
Start rabbitmq server $ ./rabbitmq-server &
I use the below script file to start RabbitMQ server whenever I log on.
#!/bin/sh
cd /home/myusername/myproject/RabbitMQ/rabbitmq-server-3.2.3/scripts
export ERLANG="/home/myusername/myproject/RabbitMQ/erlang/bin"
export PATH=${ERLANG}:${PATH}
./rabbitmq-server &

Resources