Writing a robust deamon with eventmachine and ruby

241 views
Skip to first unread message

timu

unread,
Aug 5, 2009, 6:31:13 AM8/5/09
to EventMachine
I have been digging around the web for a sample implementation of a
daemon that handles pid files, running under different users etc.

The closest I have come is the ftp server implementation on github but
that is pretty simple too.

Does anybody know of a sample eventmachine daemon written in ruby?

One that has a start/stop script, handles pid file creation and
deletion and one that can run under a different user privilege?


Thanks.

James Tucker

unread,
Aug 5, 2009, 6:42:43 AM8/5/09
to eventm...@googlegroups.com

On 5 Aug 2009, at 11:31, timu wrote:

>
> I have been digging around the web for a sample implementation of a
> daemon that handles pid files, running under different users etc.

daemon-kit[1] has some great stuff for those that want help with
this / don't want to write it, and it's much cleaner and more complete
than a lot of other offerings.

HTH

[1] http://github.com/kennethkalmer/daemon-kit/tree/master

timu

unread,
Aug 5, 2009, 7:01:15 AM8/5/09
to EventMachine

>
> daemon-kit[1] has some great stuff for those that want help with  
> this / don't want to write it, and it's much cleaner and more complete  
> than a lot of other offerings.
>


I looked at that. I installed the gem and created a default daemon
which created several directories of files and had no option for
shedding user privileges. I guess I was hoping for something easier to
follow. I have a pretty simple daemon which only consists of one
file.

Kenneth Kalmer

unread,
Aug 5, 2009, 7:15:18 AM8/5/09
to EventMachine
Privilege dropping is high on the todo list, I'm just wrapping up some
ruote integration work on another branch first.

As for the single file daemon, daemon_kit doesn't simplify that at
all. After a few more minor tweaks and patches on the 0.1 line I'll be
starting a complete rewrite of the project. One of my biggest aims for
the rewrite is to provide a "mini" mode, which you can think of as a
sinatra for daemon processes. That is still a while off though, I seem
to be struggling to find free time lately.

Try to forgive the project layout if you can, and slap your code in
the generated libexec/ file. I hope it works out for you until the
mini-mode comes along.

Best

--
Kenneth Kalmer
http://www.opensourcery.co.za
@kennethkalmer

snacktime

unread,
Aug 10, 2009, 4:19:36 PM8/10/09
to EventMachine
I much prefer using runnit for stuff like this when it's an option.
It's simple to configure and robust.

Tim Uckun

unread,
Aug 10, 2009, 7:48:35 PM8/10/09
to eventm...@googlegroups.com
On Tue, Aug 11, 2009 at 8:19 AM, snacktime<snac...@gmail.com> wrote:
>
> I much prefer using runnit for stuff like this when it's an option.
> It's simple to configure and robust.
>


A couple of people have reccomended this and I'll probably look into
it. It seems like "yet another thing to install, maintain, learn,
replicate etc" but obviously people seem to like it.

Sho Fukamachi

unread,
Aug 11, 2009, 1:09:38 AM8/11/09
to eventm...@googlegroups.com
That's the second time I've heard someone mention this "runnit" but
never found out what it was.

Gpt a link or something?

thanks

Tim Uckun

unread,
Aug 11, 2009, 2:12:35 AM8/11/09
to eventm...@googlegroups.com
On Tue, Aug 11, 2009 at 5:09 PM, Sho Fukamachi<sho.fu...@gmail.com> wrote:
>
> That's the second time I've heard someone mention this "runnit" but
> never found out what it was.
>
> Gpt a link or something?

Here is the link.

http://smarden.org/runit/

It's a port of daemontools which was written by DJB (of qmail and
djbdns fame). I used daemontools a very long time ago when I was
running djbdns. My biggest grief was the non standard directory
layout and "yet another thing to learn, maintain, and upgrade"
headache.

Since runit is in the debian package list I hope it's been morphed to
be more standard.

Sho Fukamachi

unread,
Aug 11, 2009, 2:50:58 AM8/11/09
to eventm...@googlegroups.com
Thanks Tim. Yeah, I heard of that one. Maybe people spelling it with
two "n"s was the source of my confusion...

Agree completely with your "yet another thing to learn, maintain, and
upgrade" atttitude btw, starting and running a daemon is not, or
should not be, rocket science and there is no reason it can't all be
handled in pure ruby.

I have also had success with Kenneth Kalmer's daemon-kit project as
mentioned earlier in the thread; I think that's your best bet for now.
Reply all
Reply to author
Forward
0 new messages