Excuse me if the subject is vague, but I tried to describe my problem to the best of my possibilities. I have my raspberry pi which I want to deploy to using codeship. Rsyncing the files works perfectly, but when I am to restart my application using pm2
my problem occurs.
I have installed node and pm2 using the node version manager NVM.
ssh [email protected] 'source /home/pi/.bashrc; cd project; pm2 restart app.js -x -- --prod'0 min 3 sec
bash: pm2: command not found
I have even added:
shopt -s expand_aliases
in the bottom of my bashrc
but it doesn't help.
How can I make it restart my application after I have done a deploy? Thanks in advance for your sage advice and better wisdom!
EDIT 1: My .bashrc http://pastie.org/10529200
My $PATH: /home/pi/.nvm/versions/node/v4.2.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
EDIT 2: I added /home/pi/.nvm/versions/node/v4.2.0/bin/pm2
which is the full path to pm2 and now I get the following error: /usr/bin/env: node: No such file or directory
It seems that even if I provide the full path, node isn't executed.
pm2
an alias? If so it probably won't work. Your better off writing a script to handle this and executing that script. Also the ssh command you have is assuming your running in a shell however that isn't a good assumption. Perhaps starting your ssh command with"/bin/bash -c 'source ....'"
which leads back to the write a script comment above. Finally, does thepm2
command require a tty? with out the-t
option a tty will not be allocated. Some programs assume you have one if it is usually executed from an interactive shell unlike the example you provided./bin/bash -c "nvm use 4.2.0"
to try and enable node. Unfortunately it doesn't work./bin/bash: nvm: command not found /bin/bash: pm2: command not found
/home/pi/.bashrc
file andecho $PATH
output.bash -c
then it doesn’t work because once the -c completes the bash shell exits and any envirinment created within is gone. You have a path problem./bin/bash -c ’echo $PATH’
and see what is missing. (single quotes not double quotes).