bin/clockworkd in clockwork-0.6.2 vs bin/clockworkd in clockwork-0.7.0

- old
+ new

@@ -46,10 +46,13 @@ opts.on('-c', '--clock=FILE',"Clock .rb file. Default is #{@options[:file]}.") do |clock_file| @options[:file] = clock_file @options[:file] = "./#{@options[:file]}" unless @options[:file].match(/^[\/.]/) @options[:file] = File.expand_path(@options[:file]) end + opts.on('-d', '--dir=DIR', 'Directory to change to once the process starts') do |dir| + @options[:current_dir] = File.expand_path(dir) + end end @args = opts.parse!(ARGV) def optparser_abort(opts,message) @@ -77,9 +80,12 @@ else puts "#{process_name}: No output will be printed out (run with --log if needed)" end Daemons.run_proc(process_name, :dir => @options[:pid_dir], :dir_mode => :normal, :monitor => @options[:monitor], :log_dir => @options[:log_dir], :log_output => @options[:log_output], :ARGV => @args) do |*args| + # daemons changes the current working directory to '/' when a new process is + # forked. We change it back to the project root directory here. + Dir.chdir(@options[:current_dir]) if @options[:current_dir] require @options[:file] Clockwork::run end