Daemonizing: What is the Community Using

Hi friends.

Until recently I’ve been using Daemon kit on a Ruby on Rails project
I’ve
been developing for work. Namely I’m trying to monitor a Delayed Job
queue.
This has worked fine during development as I’ve not had to actually run
my
script as an actual daemon. Sadly, Daemon kit fails utterly for
production
RoR applications as it uses both ObjectSpace (which we can enable) and
forks, which is something JRuby just doesn’t like.

I’m wondering what the community as a whole is using. I’m currently
looking
into TorqueBox. My only qualm with this solution is that it seems like
it
isn’t as convenient as the Glassfish gem for development.

Thoughts? Anecdotes?

James

On Sep 21, 2009, at 7:52 AM, James H. wrote:

I’m wondering what the community as a whole is using. I’m currently
looking into TorqueBox. My only qualm with this solution is that it
seems like it isn’t as convenient as the Glassfish gem for
development.

For work I am spawning off JRuby daemons from a regular Ruby script.
The Ruby script parses all the command line options and constructs the
command line to call JRuby. On the flip side, the Ruby script also
shuts down the JRuby daemon when we deploy new code or when something
breaks. It works very well, and we’ve not had any problems with this
arrangement.

We are using the Servolux gem for daemonizing and the server
processes. GitHub - TwP/servolux: Threads : Servers : Forks : Daemons

Blessings
TwP


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Mon, Sep 21, 2009 at 8:59 AM, Tim P. [email protected] wrote:

On Sep 21, 2009, at 7:52 AM, James H. wrote:

I’m wondering what the community as a whole is using. I’m currently
looking into TorqueBox. My only qualm with this solution is that it seems
like it isn’t as convenient as the Glassfish gem for development.

We are using the Servolux gem for daemonizing and the server processes.
GitHub - TwP/servolux: Threads : Servers : Forks : Daemons

This is a timely thread. We need a simple daemon which runs with
sub-minute granularity (so we can’t use cron). The daemon runs search
reindexing process every n seconds.

Questions:

  • How does this work with deployment as a War? Do you have to build a
    UI for controlling and monitoring the daemon?
  • What about detection of crashes or memory leaks? In a standard
    non-jRuby rails environment, we’d use Monit for this. Does servolux
    or some other solution handle that?

Thanks,
– Chad


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Mon, Sep 21, 2009 at 15:52, James H. [email protected]
wrote:

into TorqueBox. My only qualm with this solution is that it seems like it
isn’t as convenient as the Glassfish gem for development.

Thoughts? Anecdotes?

James

Run your script with nohup and there you have your daemon. I also use
this kind of skeleton in the “daemon script” itself

File.open(PID_FILE, “w”) { |f| f << $$ }
def clean_up!
FileUtils.rm PID_FILE
end
Signal.trap 15 { clean_up! }
begin

ensure
clean_up!
end


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Mon, Sep 21, 2009 at 6:52 AM, James H.
[email protected]wrote:

into TorqueBox. My only qualm with this solution is that it seems like it
isn’t as convenient as the Glassfish gem for development.

Maybe this is what you are saying as well but anyway, GlassFish gem
supports
daemonizing on linux and solaris platforms. Just run glassfish with -d
flag.

I heard from many users that it works just fine.

-vivek.

On Sep 21, 2009, at 12:17 PM, Chad W. wrote:

GitHub - TwP/servolux: Threads : Servers : Forks : Daemons

This is a timely thread. We need a simple daemon which runs with
sub-minute granularity (so we can’t use cron). The daemon runs search
reindexing process every n seconds.

Questions:

  • How does this work with deployment as a War? Do you have to build a
    UI for controlling and monitoring the daemon?

There is no war file involved in the context in which we are using
Servolux. All control and monitoring of the daemon process is done by
hand right now (no monit, god, or nagios). We are using “vlad” for
deployment, though.

  • What about detection of crashes or memory leaks? In a standard
    non-jRuby rails environment, we’d use Monit for this. Does servolux
    or some other solution handle that?

Servolux will attempt to determine if the daemon process started
successfully or not and report the status. After the daemon starts,
though, no more monitoring is performed. You should use another tool
for server monitoring.

Blessings,
TwP


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

My own experience. Daemonizing is not simple to do reliably with lots
of
daemons and pid files are inherently unreliable, avoid them if you can.
runit is a good alternative when it’s the right fit. For queue type
stuff,
running stuff frequently with cron will thrash your servers with all
those
processes constantly starting up. For delayed jobs, we use webhooks.
We
stick stuff into a queue that does an http post back to our rails app
that
processes the delayed job. Leverages our existing infrastructure, no
custom
job runners, etc… works great and we push through about a million or
more
jobs a day. Our queue servers used to run with a load average of around
20,
not they are down to 1-2.
Chris

I’ll second the daemonizing of GlassFish Gem as long as you’re on
Linux or Solaris, especially if (as it sounds) you’re already using it
for development. Seems like it would make your entire deployment story
nicely simple.

On Tue, Sep 22, 2009 at 2:28 PM, Vivek P. [email protected]
wrote:

RoR applications as it uses both ObjectSpace (which we can enable) and
I heard from many users that it works just fine.

-vivek.

Thoughts? Anecdotes?

James


Eagle K.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

JMS , durable topics, etc ?

On Wed, Sep 23, 2009 at 2:24 AM, snacktime [email protected] wrote:

Chris

RoR applications as it uses both ObjectSpace (which we can enable) and


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Indeed it does, but this is not quite what I meant. I’m more interested
in
how people are daemonizing tasks. Take for instance the Delayed Job gem
and
it’s Worker class. The Worker class monitors a queue in your database
that
holds a list of tasks that need to be performed. You such a class should
be
running as a daemon for a productionalized version of your application.

Making a daemon in MRI is straight forward: fork a process and hand off
control to the init process. Since JRuby doesn’t do forking, I’m curious
how
people are handling this. The consensus seems to be running some script
in
the background with “nohup”. Example:

nohup jruby script/daemon < /dev/null > my_log_file.log 2>&1

James

Generally speaking, I recommend DaemonTools to keep things alive

http://cr.yp.to/daemontools.html

It’s an alternative to init.d/ scripts and generally does a good job
of managing processes. It’s what I use to manage JBoss itself on
torquebox.org.

-Bob

VERYYYY interesting. Do you perchance have any introductions to
webhooks?
I’m not familiar with this topic.

James

On Thu, Sep 24, 2009 at 6:35 AM, James H.
[email protected]wrote:

VERYYYY interesting. Do you perchance have any introductions to webhooks?
I’m not familiar with this topic.

It’s just a fancy name for an http callback. We stole the rest of the
architecture idea from how google is using them to manage similar
delayed
jobs. The basic architecture is that we have a queue server that
accepts
http POST requests to add items to the queue. Our web apps then make
http
requests to add jobs to the queue server. The queue server then takes
the
url for the queue, and posts the job to that url, which processes the
task
and returns a response. We have a number of different queues each with
their own url. The queue server is written with eventmachine.

Chris