Forum: 
Tags: 

node app as daemon

Cem Incecinar's picture

Hello,

I dont know am i asking a naive question or not but i was trying to find out something in NodeJS appliance. "Includes custom nodejs initscript for running node app as daemon" as stated but cant figure it out where it is, how can i found the initscript and documentation about it to learn how i can use it in appliance.

Thank you

https://gist.github.com/1065350 promises to daemonize. I get an error, however. I don't if it's the script or my total ignorance.


Cem Incecinar's picture

Appliance says its included already so im just looking where it is

http://www.turnkeylinux.org/nodejs

Check Features

Jeremy Davis's picture

Please note I have not used the NodeJS appliance so it is a case of blind leading the blind!

Perhaps there are links to relevant references on the 'Control Panel' page?

Otherwise if the daemon is already started you could check using a command like 'ps aux|grep node' and see what that returns. If it is running (and includes node in it's name) it should show up and hopefully with a path. You could also try something like 'ps aux|grep tklweb' (as the appliance page states that Node is installed to /opt/tklweb-cp so perhaps that's what it is called?)

Another thought is that AFAIK daemons require an init script (which should be found in /etc/init.d) and often (but not always) daemons have their settings defined in /etc/defaults. These could be places to look for the init script.

If you can find the script but it still means nothing to you, feel free to post it and I am willing to try to help you decode it (although no promises on whether or not I will be able to be of any help).

I've had to start my node site (in opt) with npm start /path/to/site & in rc.local for the timebeing. Looking for a better way.


Alon Swartz's picture

The initscript that's included in all nodejs based appliances is located at: /etc/init.d/nodejs

It sources /etc/default/nodejs looking for NODEJS_EXEC, which is then used to start the app.

For example, in the nodejs appliance:

nodejs# cat /etc/default/nodejs
NODEJS_EXEC=/opt/tklweb-cp/run.sh

nodejs# cat /opt/tklweb-cp/run.sh
#!/bin/sh

cd `dirname $0`
node app.js

BTW, the etherpad appliance is configured with NODEJS_EXEC=/opt/etherpad/bin/safeRun.sh

Hope the above helps...

Cem Incecinar's picture

Thank you for reply even its late. That will be more usefull.

Post new comment