zerowidth / camper_van

A Campfire to IRC bridge
MIT License
129 stars 25 forks source link

Run camper_van as a daemon #31

Closed yorickpeterse closed 11 years ago

yorickpeterse commented 11 years ago

This is a rather crude solution but the easiest one in the way camper_van is currently set up.

To daemonize a process run camper_van with -d/--daemon. A PID file (set to /var/run/camper_van.pid by default) can be specified using -i/--pid (-p is already taken by an SSL related option).

I haven't attached any tests since I'm not really sure on how to test a daemonized process since said process would also run test related code (due to Process.daemon forking the currently running process).

zerowidth commented 11 years ago

Oh sweet, I didn't know about Process.daemon! Only one question: do you think a log file should be required? The default is STDOUT, and since that's closed on daemonization, you'd end up with a server process without any way of knowing if it's working correctly (at least not via logging).

yorickpeterse commented 11 years ago

Hm, I'd say that when turning itself into a daemon a log file would be required. Would this validation best be placed in bin/camper_van or in lib/camper_van/server.rb?

zerowidth commented 11 years ago

Probably easiest to validate that in bin/camper_van. if opts[:daemonize] && !opts[:log_file]. Oh, and just to be safe, add a Logging.reopen after Process.daemonize.

yorickpeterse commented 11 years ago

Done!