Add option -e to set environment

This commit is contained in:
Dzmitry Plashchynski
2015-03-04 14:25:17 +02:00
parent 0afdab02ac
commit e96d71552e
5 changed files with 15 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ module Crono
end
def load_rails
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = config.environment
require 'rails'
require File.expand_path("config/environment.rb")
::Rails.application.eager_load!
@@ -91,7 +92,10 @@ module Crono
opts.on("-d", "--[no-]daemonize", "Daemonize process (Default: #{config.daemonize})") do |daemonize|
config.daemonize = daemonize
end
opts.on '-e', '--environment ENV', "Application environment (Default: #{config.environment})" do |env|
config.environment = env
end
end.parse!(argv)
end
end

View File

@@ -8,12 +8,14 @@ module Crono
attr_accessor :logfile
attr_accessor :pidfile
attr_accessor :daemonize
attr_accessor :environment
def initialize
self.cronotab = CRONOTAB
self.logfile = LOGFILE
self.pidfile = PIDFILE
self.daemonize = false
self.environment = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development"
end
end
end