restart at reboot

22 views
Skip to first unread message

merr...@gmail.com

unread,
Mar 31, 2010, 12:48:42 AM3/31/10
to Daemon Kit

Hello,

I've been browsing the docs contemplating using daemon-kit to
daemonize some ruby code. One question I haven't found an answer for
is how the daemon integrates with machine startup and shutdown. (I'm
on Unbuntu 9.10). I was expecting to find something related to init.d
in the code, but didn't really see anything. Does cap deploy sort this
out for me? Or do I have to hook it up myself somehow? Or do people
mostly use monit for this?

John

http://rubyreflector.com

Kenneth Kalmer

unread,
Mar 31, 2010, 6:01:04 AM3/31/10
to daemo...@googlegroups.com

Hi John

I have to admit that I have absolutely no experience with writing init
scripts for any *nix. Currently, and in the past, I've always used a
tool like monit/god to ensure my daemons are up and running, even
across reboots. Recently I've been leaning towards using runit more
and more, but not for my daemons just yet...

HTH

Regards


--
Kenneth Kalmer
kenneth...@gmail.com
http://opensourcery.co.za
@kennethkalmer

John Merrells

unread,
Mar 31, 2010, 10:41:16 AM3/31/10
to daemo...@googlegroups.com

On Mar 31, 2010, at 3:01 AM, Kenneth Kalmer wrote:

> I have to admit that I have absolutely no experience with writing init
> scripts for any *nix. Currently, and in the past, I've always used a
> tool like monit/god to ensure my daemons are up and running, even
> across reboots. Recently I've been leaning towards using runit more
> and more, but not for my daemons just yet...

Yes, that's helpful. Thanks.

I'm finding there's a bit of a gap between *nix and ruby, which makes
setting up machines and deploying code it bit too troublesome for the
application developer. I guess I just have to knuckle down and learn
more about what goes on down there in the plumbing.

Time to learn chef.... and relearn capistrano...

John

Marius Seritan

unread,
Mar 31, 2010, 10:45:24 AM3/31/10
to Daemon Kit
You don't need to go all the way to chef. I am starting my ruby
daemons from /etc/init.d scripts. Take a simple one (memcached), copy
and edit. You also need to link it in /etc/rc3.d.

Marius

John Merrells

unread,
Mar 31, 2010, 10:54:11 AM3/31/10
to daemo...@googlegroups.com

On Mar 31, 2010, at 7:45 AM, Marius Seritan wrote:

> You don't need to go all the way to chef. I am starting my ruby
> daemons from /etc/init.d scripts. Take a simple one (memcached), copy
> and edit. You also need to link it in /etc/rc3.d.

Thanks. That's a good suggestion.

I'm interested in chef for other reasons too. I'm working towards spinning
up machines on demand, so in theory chef would create the init.d script,
or capistrano would do it. A work in progress.

It'd be neat of the daemon-kit cap deploy could create and deploy the
init.d script.... one less moving part to deal with by hand.

I've been using monit, but at Kenneth's suggestion I'm reading about
God now.... which seems much clearer to my ruby brain than the
monit script.

John

Josh Owens

unread,
Mar 31, 2010, 8:02:21 PM3/31/10
to daemo...@googlegroups.com
I would second the suggestion of using God (as long as it is on 1.8.7 or higher) as it offers the added functionality of monitoring the daemon and being able to try to restart it or even bounce it for memory leaks, etc.  There are plenty of God init.d scripts floating around on the internet to make sure it comes up on boot.

That is what I use.

--Josh


John

--
You received this message because you are subscribed to the Google Groups "Daemon Kit" group.
To post to this group, send email to daemo...@googlegroups.com.
To unsubscribe from this group, send email to daemon-kit+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/daemon-kit?hl=en.


John Merrells

unread,
Apr 12, 2010, 1:37:31 PM4/12/10
to daemo...@googlegroups.com

On Mar 31, 2010, at 5:02 PM, Josh Owens wrote:

> I would second the suggestion of using God (as long as it is on 1.8.7 or higher) as it offers the added functionality of monitoring the daemon and being able to try to restart it or even bounce it for memory leaks, etc. There are plenty of God init.d scripts floating around on the internet to make sure it comes up on boot.

To close out this thread for posterity.

I ended up using 'runit' to start/stop/restart my daemon process. That's run-it, not r-unit. It uses a supervisor process rather than a pid file to manage the process. It's very neat once you get past it's oldy worldy unixy terseness. This is the runit 'run' file I'm using....

--
#!/bin/sh
cd /root/my-daemon
exec 2>&1
exec \
/usr/bin/env \
HOME=/root \
bin/my-daemon
---

For extra points runit also pipes stdout to a file and does log rotation. It also provides an init.d interface and a pid file, so that monit/god/nagios has something to watch and interface with.

John

Reply all
Reply to author
Forward
0 new messages