System: ubuntu 16
I have a working node app on a server. In package.json there is script with options to execute:
- "start-dev": "cross-env NODE_ENV=development nodemon ./bin/www"
- "prod": "cross-env NODE_ENV=production node ./bin/www"
- "dev": "cross-env NODE_ENV=development node ./bin/www"
What is needed:
- use a service that would start app on server reboot and generally keep it running all the time (I am using forever now).
- Start an app as npm script from package.json source from root directory
Right now I can start forever by going to app directory and typing this command:
forever start ./bin/www
but there is no control over the environment.
Additionally, when I try this from root directory - it fails:
forever start /home/myapp/bin/www
How can I start forever from root directory AND using npm script? I assume that initial script should be placed in
/etc/rc.local