iron_worker_ng 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +165 -9
- data/VERSION +1 -1
- data/bin/iron_worker +6 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -84,18 +84,35 @@ To get a bunch of extra output to debug things, turn it on using:
|
|
84
84
|
IronCore::Logger.logger.level = ::Logger::DEBUG
|
85
85
|
|
86
86
|
|
87
|
-
## IronWorkerNG::Code::
|
87
|
+
## IronWorkerNG::Code::Base API
|
88
88
|
|
89
|
-
The IronWorkerNG::Code::
|
89
|
+
The IronWorkerNG::Code::Base class will help you package your code for upload, but to upload it to the cloud, you'll need to use the `IronWorkerNG::Client` class.
|
90
90
|
|
91
91
|
### initialize(*args)
|
92
92
|
|
93
93
|
Create new code package with the specified args.
|
94
94
|
|
95
95
|
```ruby
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
code_from_workerfile = IronWorkerNG::Code::Base.new(:workerfile => 'example.worker')
|
97
|
+
code_with_name = IronWorkerNG::Code::Base.new(:exec => 'example.rb', :name => 'Example')
|
98
|
+
code_with_guessed_name = IronWorkerNG::Code::Base.new(:exec => 'example.rb')
|
99
|
+
code = IronWorkerNG::Code::Base.new
|
100
|
+
```
|
101
|
+
|
102
|
+
### runtime()
|
103
|
+
|
104
|
+
Return the code package's runtime.
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
puts code.runtime
|
108
|
+
```
|
109
|
+
|
110
|
+
### runtime=(runtime)
|
111
|
+
|
112
|
+
Sets the code package's runtime. If no runtime provided it defaults to 'ruby'.
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
code.runtime = 'ruby'
|
99
116
|
```
|
100
117
|
|
101
118
|
### name()
|
@@ -114,6 +131,23 @@ Sets the code package's name.
|
|
114
131
|
code.name = 'CoolWorker'
|
115
132
|
```
|
116
133
|
|
134
|
+
### remote_build_command(cmd)
|
135
|
+
### build(cmd)
|
136
|
+
|
137
|
+
Command which will be executed once (on worker upload). Can be used for heavy tasks like building your worker from sources. Check https://github.com/iron-io/iron_worker_examples/tree/master/binary/phantomjs for real world example.
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
code.remote_build_command('curl http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.4.6.tar.bz2 -o linux-3.4.6.tar.bz2 && tar xf linux-3.4.6.tar.bz2')
|
141
|
+
```
|
142
|
+
|
143
|
+
### run()
|
144
|
+
|
145
|
+
Runs code package on your local box. Can be useful for testing.
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
code.run
|
149
|
+
```
|
150
|
+
|
117
151
|
### hash_string()
|
118
152
|
|
119
153
|
Return the hash string for the code package. If you want to prevent uploading unchanged code packages, you can use it to check if any changes were made. It's very efficient, so it shouldn't cause any performance impact.
|
@@ -123,6 +157,7 @@ puts code.hash_string
|
|
123
157
|
```
|
124
158
|
|
125
159
|
### merge_file(path, dest = '')
|
160
|
+
### file(path, dest = '')
|
126
161
|
|
127
162
|
Merge the file located at `path` into the code package. If `dest` is set, it will be used as the path to a directory within the zip, into which the file will be merged. If the directory does not exist, it will be automatically created.
|
128
163
|
|
@@ -132,6 +167,7 @@ code.merge_file 'clients.csv', 'information/clients' # will be in information/cl
|
|
132
167
|
```
|
133
168
|
|
134
169
|
### merge_dir(path, dest = '')
|
170
|
+
### dir(path, dest = '')
|
135
171
|
|
136
172
|
Recursively merge the directory located at path into the code package. If `dest` is set, it will be used as the path to a directory within the zip, into which the directory specified by `path` will be merged. If `dest` is set but does not exist, it will be automatically created.
|
137
173
|
|
@@ -140,17 +176,23 @@ code.merge_dir '../config' # will be in the same directory as worker
|
|
140
176
|
code.merge_dir 'lib', 'utils' # will be in utils subdirectory, accessible as utils/lib
|
141
177
|
```
|
142
178
|
|
143
|
-
|
179
|
+
## IronWorkerNG::Code::Ruby API
|
144
180
|
|
145
|
-
|
181
|
+
Specific methods for ruby runtime.
|
182
|
+
|
183
|
+
### merge_exec(path, klass = nil)
|
184
|
+
### exec(path, klass = nil)
|
185
|
+
|
186
|
+
Merge the exec located at `path`. If `klass` is provided, it'll try to instantiate it, set attrs from params and fire up `run` method when executed.
|
146
187
|
|
147
188
|
```ruby
|
148
|
-
code.merge_exec 'my_worker.rb'
|
189
|
+
code.merge_exec 'my_worker.rb'
|
149
190
|
```
|
150
191
|
|
151
192
|
### merge_gem(name, version = '>= 0')
|
193
|
+
### gem(name, version = '>= 0')
|
152
194
|
|
153
|
-
Merge a gem with dependencies. Please note that gems which contains binary extensions will not be merged for now, as binary extensions are not supported at this time; we have [a set](http://dev.iron.io/worker/reference/environment/?lang=ruby#ruby_gems_installed) of the most common gems with binary extensions preinstalled for your use. You can use version constrains if you need a specific gem version.
|
195
|
+
Merge a gem with dependencies. Please note that gems which contains binary extensions will not be merged for now, as binary extensions are not supported at this time; we have [a set](http://dev.iron.io/worker/reference/environment/?lang=ruby#ruby_gems_installed) of the most common gems with binary extensions preinstalled for your use. You can use version constrains if you need a specific gem version. Please note that `git` and `path` gems aren't supported yet.
|
154
196
|
|
155
197
|
```ruby
|
156
198
|
code.merge_gem 'activerecord'
|
@@ -158,6 +200,7 @@ code.merge_gem 'paperclip', '< 3.0.0,>= 2.1.0'
|
|
158
200
|
```
|
159
201
|
|
160
202
|
### merge_gemfile(path, *groups)
|
203
|
+
### gemfile(path, *groups)
|
161
204
|
|
162
205
|
Merge all gems from specified the groups in a Gemfile. Please note that this will not auto-require the gems when executing the worker.
|
163
206
|
|
@@ -165,6 +208,119 @@ Merge all gems from specified the groups in a Gemfile. Please note that this wil
|
|
165
208
|
code.merge_gemfile '../Gemfile', 'common', 'worker' # merges gems from common and worker groups
|
166
209
|
```
|
167
210
|
|
211
|
+
## IronWorkerNG::Code::Binary API
|
212
|
+
|
213
|
+
Specific methods for binary (freeform) runtime.
|
214
|
+
|
215
|
+
### merge_exec(path)
|
216
|
+
### exec(path)
|
217
|
+
|
218
|
+
Merge the exec located at `path`.
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
code.merge_exec 'my_worker.sh'
|
222
|
+
```
|
223
|
+
|
224
|
+
## IronWorkerNG::Code::Go API
|
225
|
+
|
226
|
+
Specific methods for go runtime. It'll run provided exec via 'go run'.
|
227
|
+
|
228
|
+
### merge_exec(path)
|
229
|
+
### exec(path)
|
230
|
+
|
231
|
+
Merge the exec located at `path`.
|
232
|
+
|
233
|
+
```ruby
|
234
|
+
code.merge_exec 'my_worker.go'
|
235
|
+
```
|
236
|
+
|
237
|
+
## IronWorkerNG::Code::Java API
|
238
|
+
|
239
|
+
Specific methods for java runtime.
|
240
|
+
|
241
|
+
### merge_exec(path, klass = nil)
|
242
|
+
### exec(path, klass = nil)
|
243
|
+
|
244
|
+
Merge the exec located at `path`. If class isn't provided, it'll relay on jar's manifest.
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
code.merge_exec 'my_worker.jar'
|
248
|
+
```
|
249
|
+
|
250
|
+
### merge_jar(path)
|
251
|
+
### jar(path)
|
252
|
+
|
253
|
+
Merge the jar located at `path`. It'll be added to classpath when executing your worker.
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
code.merge_jar 'xerces.jar'
|
257
|
+
```
|
258
|
+
|
259
|
+
## IronWorkerNG::Code::Mono API
|
260
|
+
|
261
|
+
Specific methods for mono (.net) runtime.
|
262
|
+
|
263
|
+
### merge_exec(path)
|
264
|
+
### exec(path)
|
265
|
+
|
266
|
+
Merge the exec located at `path`.
|
267
|
+
|
268
|
+
```ruby
|
269
|
+
code.merge_exec 'my_worker.exe'
|
270
|
+
```
|
271
|
+
|
272
|
+
## IronWorkerNG::Code::Node API
|
273
|
+
|
274
|
+
Specific methods for node runtime.
|
275
|
+
|
276
|
+
### merge_exec(path)
|
277
|
+
### exec(path)
|
278
|
+
|
279
|
+
Merge the exec located at `path`.
|
280
|
+
|
281
|
+
```ruby
|
282
|
+
code.merge_exec 'my_worker.js'
|
283
|
+
```
|
284
|
+
|
285
|
+
## IronWorkerNG::Code::Perl API
|
286
|
+
|
287
|
+
Specific methods for perl runtime.
|
288
|
+
|
289
|
+
### merge_exec(path)
|
290
|
+
### exec(path)
|
291
|
+
|
292
|
+
Merge the exec located at `path`.
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
code.merge_exec 'my_worker.pl'
|
296
|
+
```
|
297
|
+
|
298
|
+
## IronWorkerNG::Code::PHP API
|
299
|
+
|
300
|
+
Specific methods for PHP runtime.
|
301
|
+
|
302
|
+
### merge_exec(path)
|
303
|
+
### exec(path)
|
304
|
+
|
305
|
+
Merge the exec located at `path`.
|
306
|
+
|
307
|
+
```ruby
|
308
|
+
code.merge_exec 'my_worker.php'
|
309
|
+
```
|
310
|
+
|
311
|
+
## IronWorkerNG::Code::Python API
|
312
|
+
|
313
|
+
Specific methods for python runtime.
|
314
|
+
|
315
|
+
### merge_exec(path)
|
316
|
+
### exec(path)
|
317
|
+
|
318
|
+
Merge the exec located at `path`.
|
319
|
+
|
320
|
+
```ruby
|
321
|
+
code.merge_exec 'my_worker.py'
|
322
|
+
```
|
323
|
+
|
168
324
|
# Upload Your Worker
|
169
325
|
|
170
326
|
When you have your code package, you are ready to upload and run it on the IronWorker cloud.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.5
|
data/bin/iron_worker
CHANGED
@@ -61,6 +61,7 @@ if command == 'codes.create'
|
|
61
61
|
end
|
62
62
|
|
63
63
|
name = nil
|
64
|
+
max_concurrency = nil
|
64
65
|
|
65
66
|
opts = OptionParser.new do |opts|
|
66
67
|
opts.banner = "usage: iron_worker #{command} [OPTIONS]"
|
@@ -69,6 +70,10 @@ if command == 'codes.create'
|
|
69
70
|
name = v
|
70
71
|
end
|
71
72
|
|
73
|
+
opts.on('-c', '--max-concurrency CONCURENCY', Integer, 'max number of concurrent workers for this code package') do |v|
|
74
|
+
max_concurrency = v
|
75
|
+
end
|
76
|
+
|
72
77
|
env_opt(opts)
|
73
78
|
end
|
74
79
|
|
@@ -90,7 +95,7 @@ if command == 'codes.create'
|
|
90
95
|
|
91
96
|
IronCore::Logger.info 'IronWorkerNG', "Worker '#{code.name}' upload started"
|
92
97
|
|
93
|
-
client.codes.create(code)
|
98
|
+
client.codes.create(code, :max_concurrency => max_concurrency)
|
94
99
|
|
95
100
|
IronCore::Logger.info 'IronWorkerNG', "Worker '#{code.name}' uploaded"
|
96
101
|
elsif command == 'tasks.create' || command == 'schedules.create'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_worker_ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: '0'
|
163
163
|
segments:
|
164
164
|
- 0
|
165
|
-
hash:
|
165
|
+
hash: -584784563
|
166
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
167
|
none: false
|
168
168
|
requirements:
|