46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/employer/cli.rb', line 46
def config
if File.exists?(options[:config])
STDERR.puts "#{options[:config]} already exists."
exit 1
end
FileUtils.mkdir("config") unless File.directory?("config")
File.open(options[:config], "w") do |file|
file.write <<CONFIG
# If you're using Rails the below line requires config/environment to setup the
# Rails environment. If you're not using Rails you'll want to require something
# here that sets up Employer's environment appropriately (making available the
# classes that your jobs need to do their work, providing the connection to
# your database, etc.)
# require "./config/environment"
require "employer-mongoid"
# Setup the backend for the pipeline, this is where the boss gets the jobs to
# process. See the documentation for details on writing your own pipeline
# backend.
pipeline_backend Employer::Mongoid::Pipeline.new
# Add loggers to log. Logged output will go to all of the loggers defined here.
log_to ::Logger.new("./log/employer.log")
# Use employees that fork subprocesses to perform jobs. You cannot use these
# with JRuby, because JRuby doesn't support Process#fork.
forking_employees 4
# Use employees that run their jobs in threads, you can use these when using
# JRuby. While threaded employees also work with MRI they are limited by the
# GIL (this may or may not be a problem depending on the type of work your jobs
# need to do).
# threading_employees 4
CONFIG
end
end
|