Daemons

I

Iain Barnett

Hi,

I've got a process I'd like to daemonize, a call the twitter search API =
ever 10 minutes or so. There seem to be a few gems that purport to make =
this process easier and I was wondering if anyone could recommend (or =
tell me to avoid) any? Or just any tips to watch out for.

Any help is much appreciated.

Regards,
Iain=
 
A

Alex Young

Iain Barnett wrote in post #968104:
Hi,

I've got a process I'd like to daemonize, a call the twitter search API
ever 10 minutes or so. There seem to be a few gems that purport to make
this process easier and I was wondering if anyone could recommend (or
tell me to avoid) any? Or just any tips to watch out for.

The Daemons gem is good, but if you don't need anything fancy then
it's not much code to do it yourself:


# File lib/webrick/server.rb, line 28
def Daemon.start
exit!(0) if fork
Process::setsid
exit!(0) if fork
Dir::chdir("/")
File::umask(0)
STDIN.reopen("/dev/null")
STDOUT.reopen("/dev/null", "w")
STDERR.reopen("/dev/null", "w")
yield if block_given?
end
 
I

Iain Barnett

Iain Barnett wrote in post #968104:

The Daemons gem is good, but if you don't need anything fancy then
it's not much code to do it yourself:


# File lib/webrick/server.rb, line 28
def Daemon.start
exit!(0) if fork
Process::setsid
exit!(0) if fork
Dir::chdir("/")
File::umask(0)
STDIN.reopen("/dev/null")
STDOUT.reopen("/dev/null", "w")
STDERR.reopen("/dev/null", "w")
yield if block_given?
end


Thanks Alex, I'll give both that gem and the code a good look!

Regards,
Iain
 
J

Jeremy Hinegardner

Hi,

I've got a process I'd like to daemonize, a call the twitter search API ever 10 minutes or so. There seem to be a few gems that purport to make this process easier and I was wondering if anyone could recommend (or tell me to avoid) any? Or just any tips to watch out for.

Any help is much appreciated.

Regards,
Iain


Also take a look at the 'servolux' gem.

http://rubygems.org/gems/servolux

enjoy,

-jeremy
 
T

Tim Pease

API ever 10 minutes or so. There seem to be a few gems that purport to =
make this process easier and I was wondering if anyone could recommend =
(or tell me to avoid) any? Or just any tips to watch out for.
=20
=20
Also take a look at the 'servolux' gem.
=20
http://rubygems.org/gems/servolux
=20


require 'servolux'

daemon =3D Servolux::Daemon.new(
:name =3D> 'Twitter Search',
:pid_file =3D> '/path/to/the/pid/file.pid',
:startup_command =3D> '/path/to/your/twitter/process'
)
daemon.startup


There are some example files demonstrating how to accomplish various =
tasks:
https://github.com/TwP/servolux/tree/master/examples

And the documentation is fairly thorough:
http://rdoc.info/github/TwP/servolux/master/frames

Blessings,
TwP

PS Being the author of servolux, my opinion is completely biased :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top