Hi,
I have node installed via nvm (https://github.com/creationix/nvm). This means, that each time I want to use my node, I need to have this lines executed:
export NVM_DIR="/home/eagle-eye/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
This piece is stored in the ~/.profile , when I login using the terminal - it reads (sources) it automatically.
When pm2 deploy logs in - the file is not sourced, which leads to the fact, that I need to do the next:
"post-deploy" : ". ~/.profile ; npm install ; bower install ; pm2 startOrRestart ecosystem.json --env production"
And it's not a problem.
But, when I want to use the pm2 deploy production exec 'bower --version', it is an issue, because I do not want to type . ~/.profile each time.
I have tried to search if it's possible to integrate this default command somewhere in my ecosystem.json, however I haven't found the exact documentation of the options which could be present there. Only this article: http://pm2.keymetrics.io/docs/usage/deployment/ . Is there a full list of the options available inside the ecosystem.json?
Is that possible to configure the default command to be executed right after the ssh connection? What are the other ways to make pm2 deploy production exec <cmd> work?
Regards,
Could you put these first lines into your .bashrc, I have not any problem in my servers and NVM
@Unitech
You are correct, for some reason, when I put it to the top of .bashrc file it works.
If I put it to the bottom - it doesn't.
Strange, because I have default ubuntu .bashrc.
Thanks,
It's strange, but when i enter this command in my terminal, it runs locally:
pm2 deploy production exec "nvm use stable && pm2 stop all"
I thought it should run on my server.
My ecosystem.json:
{
/**
* Application configuration section
* http://pm2.keymetrics.io/docs/usage/application-declaration/
*/
apps : [
// First application
{
name : "my_project",
cwd : "./.build",
script : ".",
ignore_watch: [],
max_memory_restart: "64M",
instances : 2,
exec_mode : "cluster_mode",
env: {
COMMON_VARIABLE: "1234567890"
},
env_production : {
NODE_ENV: "production"
}
}
],
/**
* Deployment section
* http://pm2.keymetrics.io/docs/usage/deployment/
*/
deploy : {
production : {
user : "deployer",
host : "...",
ref : "origin/master",
repo : "...",
path : "/home/deployer/projects/my_project",
"post-deploy" : ". ~/.profile && nvm use stable && npm install && pm2 startOrGracefulReload apps.json --env production"
}
}
}
And it stops local server. What am i doing wrong? PM2 version is [email protected].
Might be your .bashrc file contains lines like these
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
That's why everything works when you put export NVM to the top of your file
Most helpful comment
Might be your .bashrc file contains lines like these
# If not running interactively, don't do anythingcase $- in*i*) ;;*) return;;esacThat's why everything works when you put export NVM to the top of your file