mirror of
https://github.com/plashchynski/crono.git
synced 2026-03-26 11:21:42 +01:00
Add option -e to set environment
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user