ralyodio / node-startup

Startup script for Linux-based systems for running node app when rebooting using an /etc/init.d script.
MIT License
779 stars 169 forks source link

The application is aborted when I open it in the browser #16

Closed Alex1990 closed 8 years ago

Alex1990 commented 10 years ago

OS: Ubuntu 14.04 LTS

When I open the application in the browser, the html file is loaded. But all others can't not be loaded because the node has been stopped.

app.log file:

/home/alexchao/www/jobcn-deploy-tool/server/index.js: 1: /home/alexchao/www/jobcn-deploy-tool/server/index.js: Syntax error: "(" unexpected

index.js file:

var fs = require('fs');
var restify= require('restify');
// ...

There is another problem that the log and pid directories require root account. When I use a normal account to login, the app will stop because of permission.

Alex1990 commented 10 years ago

When I type /etc/init.d/node-app start to test in the terminal, it's ok. When I reboot, the above problem will happen.

bastiwasni commented 10 years ago

I got the same issue on Debian 6.

When I test it with /etc/init.d/node-app start everything works fine.

On reboot my log file writes this:

/var/www/vhosts/localapp.7goods.de/node/app.js: line 1: syntax error near unexpected token ('/var/www/vhosts/localapp.7goods.de/node/app.js: line 1: var http = require('http');'

index.js file:

var http = require('http');
//...
ralyodio commented 10 years ago

Can you try setting the force flag on reboot? in the init.d script change this line to true:

FORCE_OP=false
bastiwasni commented 10 years ago

Yes I tried it already. But it doesn't change anything.

ianpgall commented 9 years ago

@Alex1990 The log and pid directories don't require root permissions. It all depends on how you setup the config, how you run the script, and permissions of the locations. If you run the script as a normal user, the normal user will own the files. If you run the script as root, the files will be created and owned by root, so your normal user won't be able to modify them after that point. A possible solution, that I'm not sure is correct, is to have the script set less strict permissions on the files. I just want to make sure - the original problem you were having was only happening on restart, right? If you started fresh, used root account for everything, and restarted, do you have the same problems?