Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Remove Lita::Daemon #62

Closed
jimmycuadra opened this issue Oct 3, 2014 · 7 comments
Closed

Remove Lita::Daemon #62

jimmycuadra opened this issue Oct 3, 2014 · 7 comments

Comments

@jimmycuadra
Copy link
Collaborator

I was sort of thinking this when it was first proposed, but wasn't totally sure and unfortunately didn't say no. Daemonization logic is not an application concern and should not be handled in Ruby code by Lita. There are plenty of process management tools available to do this for arbitrary processes without needing the application itself to be aware of how it's being run.

Lita::Daemon should emit a deprecation warning in Lita 4 and should be removed in Lita 5.

Further reading: http://www.mikeperham.com/2014/09/22/dont-daemonize-your-daemons/

@harlanbarnes
Copy link

I give this a vote of 🍦. It makes the init/runit/whatever stuff in the Chef cookbook easier to detect startup failures (thus you can ignore my comment on #61). I might go ahead and change it over that way now just to get ahead of the curve.

@jufemaiz
Copy link

Ok, while I agree with a lot of the commentary in those it would be fantastic to have some reference material to implement the changes…

@harlanbarnes
Copy link

Hi @jufemaiz - Here are a couple of ways to do it ...

  1. If you like/use runit, the Chef cookbook has a working example.
  2. If you are using your own init script and/or other shell startup, you can do something like this (as the user you want Lita to run as).
nohup /path/to/lita --log-file /path/to/logs/lita.log --pid-file /path/to/lita.pid >> /path/to/logs/console.log 2>&1 < /dev/null &

That command should:

A. put lita into the background
B. have all the STDERR and STDOUT going to /path/to/logs/console.log
C. redirect STDIN to /dev/null in case the process is blocking on reading STDIN (this is not a problem with lita, but as habit I tend to do this)
D. while keeping the SIGHUP signal from killing your process (most shells don't send SIGHUP anymore so the nohup might be irrelevant but again, i'm covering my bases.)

If you are looking to start it some other way, (i.e. upstart, systemd) I can probably help with that too. Just let me know.

@jimmycuadra
Copy link
Collaborator Author

I'll also likely be adding a systemd example to the docs site in the near future.

@jufemaiz
Copy link

Hi guys, thanks so much for the direction! Will see how I go this morning (AEST) and get back to you!

@jufemaiz
Copy link

Ok, we're gradually getting there.

Dumb question, what would prevent the PID file from being created/updated?

Self solving: --log-file and --pid-file flags are not used if not using the daemon, so we need to take care of catching the pid and creating the lita.pid file ourselves.

@jimmycuadra
Copy link
Collaborator Author

I'd really recommend not trying to implement daemonization yourself. Something will inevitably go wrong. If it were me, I'd use 1) systemd for any OS that uses it (almost everything now) 2) runit for anything still using SysV init.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants