sign in
Home | Updates | Pages | Users | Admin | Help

rubyinitd

Original article

How to create a UNIX /etc/init.d startup script with Ruby

Most init.d start-up scripts seem to be bash scripts, but you can write them with any language.

#!/usr/bin/env ruby
#
# app_name      This is a startup script for use in /etc/init.d
#
# description:  Description of program / service

APP_NAME = 'app_name'

case ARGV.first
    when 'status':
           status = 'stopped'
        puts "#{APP_NAME} is #{status}" 
    when 'start':
        # Do your thang
    when 'stop':
        # Do your thang
    when 'restart':
        # Do your thang        
end

unless %w{start stop restart status}.include? ARGV.first
        puts "Usage: #{APP_NAME} {start|stop|restart}" 
        exit
end

Powered by JunebugWiki v0.0.31 Page last edited by stoyan on December 15, 2006 05:47 PM (diff)
[readonly] Version 2 (current) «olderversions