Sha256: 284aba416353a80141feed2ced3ff100704cea1d36516875d48ed67a0b8d6468

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
require 'optparse'

# default options
OPTIONS = {
  :command          => "run",
  :environment      => "development",
  :name             => "#{Dir.pwd.split("/").last}",
}

ARGV.options do |o|
  script_name = File.basename($0)
  
  o.set_summary_indent('  ')
  o.banner =    "Usage: script/#{script_name} [OPTIONS]"
  o.define_head "Runs the Babylon Application."
  o.separator   ""
  o.separator   "Arguments :" 
  
  o.on("-c", "--command=[run|start|stop|restart]", String,
       "The command you'd like to execute",
       "Default: #{OPTIONS[:command]}")   { |OPTIONS[:command]| }
  o.on("-e", "--environment=env", String,
       "The environment to run the application (you should have defined the argument into config/config.yaml)",
       "Default: #{OPTIONS[:environment]}") { |OPTIONS[:environment]| }
  o.on("-n", "--name=app_name", String,
       "Name of your application. The pid_file will be name after this.",
       "Default: #{OPTIONS[:name]}") { |OPTIONS[:name]| }
  
  o.separator ""

  o.on_tail("-h", "--help", "Show this help message.") { puts o; exit }
  
  o.parse!
end


options = {
  :ARGV       => [OPTIONS[:command], '--', OPTIONS[:environment]],
  :app_name   => OPTIONS[:name],
  :dir        => "../tmp/pids/",
  :multiple   => false,
  :backtrace  => true
}
Daemons.run(File.dirname(__FILE__) + '/../config/boot.rb', options)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
julien51-babylon-0.1.0 templates/babylon/script/component
julien51-babylon-0.1.2 templates/babylon/script/component
julien51-babylon-0.1.3 templates/babylon/script/component