I have a Node.js app which I want to deploy on my VM machine. Before starting the app, I want to set few commands which should be read before the app is started.
I placed those commands inside .bashrc
just similar to what I have done on my local environment.
Sample Command in .bashrc
export TOY_DIR=~/work/git/toyPlayer
export TOY_PLAYER_ENV=dev
Now, when I am running my app with node app.js
. It is throwing me an error that environment not found. However this thing works perfectly on my localbox.
After some google search, I tried this command
tmux
node app.js
It started node server fine but now I am not able to exit from tmux shell. I used CTRL+C to exit but it stopped the node server.
PS: I know I can do remote login to it and work. But I am trying to learn doing things with command line.
What is the best practice to achieve this ?
PPS: I do not want to detect if the shell is controlled from SSH. I want to export some variables before starting my Node app. These variables are environment variables which are read by a config.js present inside my app.
Here is an example, How am I using the environment variables.
var env = process.env['TOY_PLAYER_ENV']
My question is How to set these variables on my remote machine ?
bg %theNumberYouGot
and it will keep running in the background. – YoMismo Mar 18 '15 at 14:18bg
command? – YoMismo Mar 20 '15 at 07:28jobs
command will show you those that are sleeping/running/... You will also be able to runbg
command which will allow you to wake up a process (the node in this case) and keep it running in the background. – YoMismo Mar 20 '15 at 09:26[1] stopped node app.js
but it keeps on running. Thanks a lot for the help..Please put this as an answer and I will be happy to accept with an upvote. – Sachin Jain Mar 20 '15 at 09:39