Sha256: b69aa32862dec1744654736586cc224514ff5b6973b408a8fc73bca91a2848cf

Contents?: true

Size: 933 Bytes

Versions: 1

Compression:

Stored size: 933 Bytes

Contents

require 'daemons'
module Ginst
  module WebServer
    class << self
      
      SERVER=File.dirname(__FILE__)+'/../app/webserver.rb'
      DAEMON_OPT = {
        :app_name   => "ginst",
        :dir_mode   => :normal,
        :ARGV       => ["status"],
        :dir        => Dir.pwd,
        :multiple   => false,
        :ontop      => false,
        :mode       => :exec,
        :monitor    => true
      }  

      def start
        fork{Daemons.run(SERVER,build_opts('start'))}
      end
      
      def stop
        Daemons.run(SERVER,build_opts('stop'))
      end
      
      def status
        Daemons.run(SERVER,build_opts('status'))
      end
      
      private
      
      def build_opts(action)
        case action
        when 'start'
          DAEMON_OPT.merge({:ARGV => [action, '--', '-e production']})
        else
          DAEMON_OPT.merge({:ARGV => [action]})
        end
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ginst-0.2.2 lib/ginst/web_server.rb