We use this without issues every day... but, the stagecoach README is confusing and doesn't really reflect our internal best practices anymore. We should rewrite that.
The key things to remember are:
* Never run anything as root! Ever! Why would you dooooo that?
Seriously, use root to configure nginx, then make a regular "nodeapps" user, give the /opt/stagecoach/apps folder away to your "nodeapps" user, and then never log in as root again as far as stagecoach is concerned. Nothing powered by node needs to run as root (:
* If forever is running as root, stop all those processes.
* If you ever ran stuff as root, "chown -R nodeapps /opt/stagecoach/apps" to clean up the permissions mess.
* In settings.production, settings.staging, etc. in your deployment folder set the username to nodeapps.
* Deploy. The site starts up.
* You can manually start or stop a site correctly by logging in as nodeapps (NOT root), and doing:
cd /opt/stagecoach/apps/myappname/current
bash deployment/stop
bash deployment/start
This is what stagecoach does.
* One exception to not running things as root: you might want to check out "mechanic," a utility we wrote that gives you all our best practices for nginx in a simple command line utility. We use it for all newer server setups. It's in npm. But, you don't have to use it.
* As for running things at boot time, that's another exception to the root rule. Just make sure that something runs /opt/stagecoach/sc-proxy/sc-start-all as root at boot time. That script will take care of using "su" to start the sites as the nodeapps user.
So one simple way is to pop that command in /etc/rc.local. That's not as classy as an upstart script but it works.