Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running a node.js service (statsd) on CentOS 6. What's the proper way to daemonize and start such a service?

Potential Daemonizers--are daemonizers supposed to be language-specific or general?:

Service starters--should these be from the system/distro, or should they be from monitoring tools such as monit?:

I'm unfortunately new to this--where can I read up on what is the most standard, classic, reliable way of doing this?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Should the app itself really know how to daemonize itself...

If your app is meant to be run as a daemon, yes, it should be fully aware of how to daemonize itself, write the appropriate files (log and PID spring to mind), and handle signal. Big WTF if this isn't the case.

If your app isn't really meant to be daemonized, or that's not it's primiary purpose, then it's your decision completely. If you want to make it easy for others, you'll probably add it. If you want to make life easier on yourself, you'll probably leave it out. People generally wont have a "WTF" response either way.

Service starters...

Each distro's packages/ports system should be responsible for modifying your generic start/stop scripts to meet their particular needs. This stuff generally ain't rocket science, but when in doubt contact the maintainers for the distro you're working on.

Monitoring tools..

Should know how to interact with the Distro's official start/stop mechanisms, and should have no idea how to interact with your program specifically (unless your program "publishes" data through a reporting mechanism, possibly including hooks for a SNMP service or similar; all this really depends on what your program does though).

share|improve this answer
    
great answer, thank you! –  elliot42 Sep 19 '12 at 4:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.