javascript - Node.js - Server crashes when started on startup, doesn't crash when manually started -
i running node.js , socket.io online chat. have created file in:
/etc/init/example.conf
it has 2 lines:
start on startup exec forever start /var/www/example.com/html/server.js //location of server file.
whenever start file upload in chat application, crashes instantly restarts.
whenever kill node process though, , start manually - works fine.
i can't logs or terminal when it's auto started - doesn't print me terminal.
i still new node.js , linux in general. node.js running on express + jade.
how determine specific cause?
i managed solve problem, after bit of searching around found out tail command.
my issue bit harder trace because node.js process started autostart when launched terminal , connected server, process running in background , wouldn't output (including exception messages).
anyway, solution worked me was:
i typed
ps aux | grep node //to find pid of node process
then went following directory
cd /proc/[pid of running node service]/fd
in fd directory there few objects can output if want attach , listen servers output including uncaught exceptions, need 1. so:
tail -f 1
that way able cause website crash , see output.