Question

Troubles with Mulit Node JS on Nginx + Forever + Cron

Posted June 7, 2014 3.1k views
https://www.digitalocean.com/community/articles/how-to-host-multiple-node-js-applications-on-a-single-vps-with-nginx-forever-and-crontab See the last comment on that article (June 6th posted by Tejas Manohar, starts with "#!/bin/sh"). I thought it might be better fit for a community question rather than a comment.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer
Hi,

Just to be clear, there are two problems? Starting your app with forever and cron on reboot isn't working and static files are 404?

First off, to serve the static files, you need to set the root directory in the server block to point to where they are. Something like:


server {
listen 80;

server_name your-domain.com;
root /var/www/your-domain.com/html/app/public;

location / {
proxy_pass http://localhost:{YOUR_PORT};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}


As for the starting the app on reboot, let's try to narrow down the problem. Can you start the app with forever just by itself:


forever start --sourceDir /var/www/[your domain]/html/app/app app.js


If so, then the problem is with the cron job. In not, then there is a problem with for ever. Could you post any error messages?
Submit an Answer