simple_worker 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/simple_worker/base.rb
CHANGED
@@ -64,7 +64,7 @@ module SimpleWorker
|
|
64
64
|
f2 = SimpleWorker::MergeHelper.check_for_file(mailer, @caller_file)
|
65
65
|
basename = File.basename(mailer, f2[:extname])
|
66
66
|
path_to_templates = params[:path_to_templates] || File.join(Rails.root, "app/views/#{basename}")
|
67
|
-
@merged_mailers[basename] = {:name=>basename, :path_to_templates=>path_to_templates, :filename =>
|
67
|
+
@merged_mailers[basename] = {:name=>basename, :path_to_templates=>path_to_templates, :filename => f2[:path]}.merge!(params)
|
68
68
|
end
|
69
69
|
|
70
70
|
def merge_folder(path)
|
@@ -1,11 +1,9 @@
|
|
1
1
|
# This is the file that gets executed on the server.
|
2
2
|
|
3
|
-
|
4
3
|
def init_database_connection(sw_config)
|
5
4
|
if sw_config
|
6
5
|
db_config = sw_config['database']
|
7
6
|
if db_config
|
8
|
-
#@logger.info "Connecting to database using ActiveRecord..."
|
9
7
|
require 'active_record'
|
10
8
|
ActiveRecord::Base.establish_connection(db_config)
|
11
9
|
end
|
@@ -77,22 +75,3 @@ def init_worker_service_for_runner(job_data)
|
|
77
75
|
end
|
78
76
|
end
|
79
77
|
|
80
|
-
|
81
|
-
run_data = JSON.load(File.open(run_data_file))
|
82
|
-
# Load in job data
|
83
|
-
job_data = JSON.load(File.open(job_data_file))
|
84
|
-
job_data.merge!(run_data)
|
85
|
-
puts 'job_data=' + job_data.inspect
|
86
|
-
|
87
|
-
sw_config = job_data['sw_config']
|
88
|
-
init_database_connection(sw_config)
|
89
|
-
init_mailer(sw_config)
|
90
|
-
SimpleWorker.disable_queueing()
|
91
|
-
runner_class = get_class_to_run(job_data['class_name'])
|
92
|
-
SimpleWorker.running_class = runner_class
|
93
|
-
runner = init_runner(runner_class, job_data, dirname)
|
94
|
-
init_worker_service_for_runner(job_data)
|
95
|
-
SimpleWorker.enable_queueing()
|
96
|
-
|
97
|
-
# Let's run it!
|
98
|
-
runner_return_data = runner.run
|
@@ -122,13 +122,18 @@ module SimpleWorker
|
|
122
122
|
#tmp_file = File.join(Dir.tmpdir(), File.basename(filename))
|
123
123
|
tmp_file = File.join(Dir.tmpdir(), 'runner.rb')
|
124
124
|
File.open(tmp_file, "w") do |f|
|
125
|
+
File.open(File.join(File.dirname(__FILE__), "server", 'runner.rb'), 'r') do |fr|
|
126
|
+
while line = fr.gets
|
127
|
+
f.write line
|
128
|
+
end
|
129
|
+
end
|
125
130
|
f.write("begin\n")#error handling block start
|
126
131
|
f.write("
|
127
132
|
# Find environment (-e)
|
128
133
|
dirname = ''
|
129
134
|
i = 0
|
130
135
|
job_data_file = run_data_file = nil
|
131
|
-
puts \"args for single file=\" + ARGV.inspect
|
136
|
+
#puts \"args for single file=\" + ARGV.inspect
|
132
137
|
ARGV.each do |arg|
|
133
138
|
if arg == \"-d\"
|
134
139
|
# the user's writable directory
|
@@ -145,9 +150,21 @@ ARGV.each do |arg|
|
|
145
150
|
i+=1
|
146
151
|
end
|
147
152
|
|
153
|
+
|
148
154
|
# Change to user directory
|
149
|
-
puts 'dirname=' + dirname.inspect
|
155
|
+
#puts 'dirname=' + dirname.inspect
|
150
156
|
Dir.chdir(dirname)
|
157
|
+
require 'json'
|
158
|
+
run_data = JSON.load(File.open(run_data_file))
|
159
|
+
# Load in job data
|
160
|
+
job_data = JSON.load(File.open(job_data_file))
|
161
|
+
job_data.merge!(run_data)
|
162
|
+
#puts 'job_data=' + job_data.inspect
|
163
|
+
|
164
|
+
sw_config = job_data['sw_config']
|
165
|
+
init_database_connection(sw_config)
|
166
|
+
init_mailer(sw_config)
|
167
|
+
|
151
168
|
")
|
152
169
|
|
153
170
|
|
@@ -221,11 +238,20 @@ end
|
|
221
238
|
#f.write File.open(filename, 'r') { |mo| mo.read }
|
222
239
|
f.write("require_relative '#{File.basename(filename)}'")
|
223
240
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
241
|
+
|
242
|
+
|
243
|
+
f.write("
|
244
|
+
SimpleWorker.disable_queueing()
|
245
|
+
runner_class = get_class_to_run(job_data['class_name'])
|
246
|
+
SimpleWorker.running_class = runner_class
|
247
|
+
runner = init_runner(runner_class, job_data, dirname)
|
248
|
+
init_worker_service_for_runner(job_data)
|
249
|
+
SimpleWorker.enable_queueing()
|
250
|
+
|
251
|
+
# Let's run it!
|
252
|
+
runner_return_data = runner.run
|
253
|
+
")
|
254
|
+
|
229
255
|
#error handling block - end
|
230
256
|
f.write("\nrescue Exception => ex
|
231
257
|
$stderr.puts '_error_from_sw_'
|
@@ -304,6 +330,7 @@ end
|
|
304
330
|
# puts " MERGED MAILERS" + merged_mailers.inspect
|
305
331
|
merged_mailers.each_pair do |k, mailer|
|
306
332
|
SimpleWorker.logger.debug "Collecting mailer #{mailer[:name]}"
|
333
|
+
puts "MAILER #{mailer.inspect}"
|
307
334
|
f.add(File.basename(mailer[:filename]), mailer[:filename])
|
308
335
|
path = mailer[:path_to_templates]
|
309
336
|
Dir["#{path}/**/**"].each do |file|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: simple_worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.12
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Travis Reeder
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-10-13 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: zip
|
@@ -44,6 +44,7 @@ extra_rdoc_files:
|
|
44
44
|
- README.markdown
|
45
45
|
files:
|
46
46
|
- lib/generators/simple_worker/simple_worker_generator.rb
|
47
|
+
- lib/generators/simple_worker/templates/template_worker.erb
|
47
48
|
- lib/simple_worker.rb
|
48
49
|
- lib/simple_worker/api.rb
|
49
50
|
- lib/simple_worker/base.rb
|