Forum: Ruby Init Script Installer

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F0223b1193ecc3a935ce41a1edd72e42?d=identicon&s=25 zdennis (Guest)
on 2006-03-13 03:37
(Received via mailing list)
I've got a few scripts which need to run as system daemons. For a while
it worked to just manually start them, but it soon became annoying, so I
wrote a little script to create and install the init scripts for me.

Here's what it does... it takes a template init script (similar to
/etc/init.d/skeleton) and updates it according to passed in arguments,
and then installs the script into /etc/init.d/

That's it... now, i just run /etc/init.d/myservice start|restart|stop

any/all feedback would be great! Thanks,

Zach

p.s. - this will only work on *nix-like systems which use systemv style
init scripts
F0223b1193ecc3a935ce41a1edd72e42?d=identicon&s=25 zdennis (Guest)
on 2006-03-13 16:52
(Received via mailing list)
Checking for feedback this morning on this thread I see that my post
doesn't make a whole lot sense. Perhaps a rephrase will help
it out, as mentionend previously I wrote an init script installer.
Currently you run it like:
   ruby install_init_script.rb myscriptname
/path/to/where/script/should/be/run

This will create an /etc/init.d script which which utilizes the
start-stop-daemon (i am on a debian system). It will handle
forking your program for you and it will run it in the background as a
system daemon.

Right now that is all it does. I would like to have it wrap the script
itself in code that generates the pid file for the user and
handles removing it etc.. I am thinking of doing something like:

   init_script_install( scriptname, path2scriptdir ) do |script,
rootdir|
      ensure_script_exists rootdir + '/' + script
      create_and_install :initscript, :script=>script,
:rootdir=>rootdir, :to => '/etc/init.d/'
      create_and_install :scriptwrapper, :script=>script
   end

Where the first 'create_and_install :initscript' creates the init
script, and the second part creates a wrapper for it which
handles the creation and removal of the pid file. For the wrapper I
think I need to either rename the original script, and put my
wrapper in it's place, then have my wrapper require the renamed script,
or I need to modify the contents of the script itself.

Anyone have any ideas or thoughts on this? I'm not looking for code,
just input and opinions. I would like to get a decent base so
I can expand this to handle other types of system init scripts ( I
believe RH doesn't use start-stop-daemon like debian does,
etc.. ) before I release on rubyforge. Thanks,

Zach
6076c22b65b36f5d75c30bdcfb2fda85?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-03-13 18:16
(Received via mailing list)
On Mar 13, 2006, at 7:51 AM, zdennis wrote:

> system daemon.
> o => '/etc/init.d/'
> Anyone have any ideas or thoughts on this? I'm not looking for
> code, just input and opinions. I would like to get a decent base so
> I can expand this to handle other types of system init scripts ( I
> believe RH doesn't use start-stop-daemon like debian does, etc.. )
> before I release on rubyforge. Thanks,
>
> Zach


Zach-

	I could use a script like this. i think its a good idea. Will you be
sharing the code? I can help test it for you if you want.

Cheers-
-Ezra
F0223b1193ecc3a935ce41a1edd72e42?d=identicon&s=25 zdennis (Guest)
on 2006-03-13 19:17
(Received via mailing list)
Ezra Zygmuntowicz wrote:
>
> Zach-
>
>     I could use a script like this. i think its a good idea. Will you be
> sharing the code?

Absolutely. I just didn't want to post anything *yet* until I got some
base capabilities put in.

 > I can help test it for you if you want.

That would be great! After work I'll get my code tested a little more
and I'll email you privately the code if that works for you.

Thanks Ezra,

Zach
58f117bf6458c7dd7bf84b9e27f73747?d=identicon&s=25 William Ramirez (mercan01)
on 2006-03-13 19:51
(Received via mailing list)
I'd also be happy to test this out.
This topic is locked and can not be replied to.