skyrunner 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -5
- data/lib/skyrunner/version.rb +1 -1
- data/lib/skyrunner.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b828d1a9dbc216ff8aca55ce2e8007f07ff1c47d
|
4
|
+
data.tar.gz: 21ed7eb84af89b74578726cb69faadc981c6fdf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f78e396093a0dcbe578b1976911b29e4eab5fdf01ecaffff0405ebbc7394b642923c5b3b47da2da6c4419168cbb8b5932646eddc3391a79c319e43b5b6e44e2a
|
7
|
+
data.tar.gz: 43e38c229e0f32c9cddc66ffa375657f96f1e2b8de18e26cf030c14e96a16d065cd813f895281b8eb7ab4cd95fc0807a778117b8f75a8dc8d1766fa0c3c9e25a
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
SkyRunner
|
2
2
|
=========
|
3
3
|
|
4
|
-
SkyRunner is a simple job execution framework that lets you run jobs which are composed of small tasks
|
4
|
+
SkyRunner is a simple job execution framework that lets you run jobs which are composed of small tasks. SkyRunner uses AWS SQS and DynamoDB for queueing and job coordination, so you don't need any servers other than your task consumers to run jobs.
|
5
5
|
|
6
|
-
The key feature provided is that once a job's last task completes, a completion method can be called so you can perform a post-processing step. For example, you may run a job that has 100 tasks that process image frames in parallel, and then when these tasks are completed you compose the frames into a video and upload it to S3.
|
6
|
+
The key feature provided is that once a job's last task completes, a completion method can be called so you can perform a post-processing step. For example, you may run a job that has 100 tasks that process image frames in parallel, and then when these tasks are completed you compose the frames into a video and upload it to S3. Of course, you can also execute another job in this method, so you can easily chain jobs together.
|
7
7
|
|
8
8
|
Add to your Gemfile:
|
9
9
|
|
@@ -19,21 +19,27 @@ bundle exec rails g sky_runner:install
|
|
19
19
|
|
20
20
|
Customize `config/initializers/skyrunner.rb`. Update `lib/tasks/skyrunner.rake` to do what you want if there are exceptions during a task.
|
21
21
|
|
22
|
+
Put your AWS keys in the usual environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. If you are running on EC2, you don't need to do this and SkyRunner will run within the machine's IAM role.
|
23
|
+
|
24
|
+
Be sure the IAM permissions are granted to create DynamoDB tables and SQS queues, and to perform all read and write operations to the table and queue you've configured for SkyRunner.
|
25
|
+
|
22
26
|
To initialize DynamoDB & SQS:
|
23
27
|
|
24
28
|
``
|
25
29
|
bundle exec rake skyrunner:init
|
26
30
|
``
|
27
31
|
|
28
|
-
To start a consumer
|
32
|
+
To start a consumer:
|
29
33
|
|
30
34
|
``
|
31
35
|
bundle exec rake skyrunner:consume
|
32
36
|
``
|
33
37
|
|
34
|
-
To gracefully shut down a consumer, send it SIGINT. It will finish up processing the
|
38
|
+
To gracefully shut down a consumer, send it SIGINT (or hit Ctrl-C if you have a console.) It will finish up processing the tasks it has de-queued before terminating.
|
35
39
|
|
36
|
-
See `jobs/example_job.rb` for an example job. To run a job, just call `execute!` on the job, passing any named job arguments you want. The job class should implement the method `run`. This method will get passed the job arguments. For each task you want consumers to run, `run` should yield an array of two elements, the first being the name of the method on the job class to run for the task, and the second a Hash of method arguments.
|
40
|
+
See `jobs/example_job.rb` for an example job. To run a job, just call `execute!` on the job, passing any named job arguments you want. The job class should implement the method `run`. This method will get passed the job arguments. For each task you want consumers to run, `run` should yield an array of two elements, the first being the name of the method on the job class to run for the task, and the second a Hash of method arguments. Note that the consumer is (by default) multi-threaded, so please be sure your task methods are thread-safe.
|
37
41
|
|
38
42
|
You can specify `on_complete` and `on_failure` method(s) to call when the tasks are all completed, or if any of them fail, respectively. These methods will also be passed the original job arguments. Importantly, the completion method is guaranteed to be called once and only once, when the final task has been completed.
|
39
43
|
|
44
|
+
If any of your tasks fail in a job, consumers will stop consuming tasks for that job and deplete any queued tasks on SQS. SkyRunner does not currently retry failed tasks, for now you'll need to implement your own retry logic in your task method instead.
|
45
|
+
|
data/lib/skyrunner/version.rb
CHANGED
data/lib/skyrunner.rb
CHANGED
@@ -90,6 +90,7 @@ module SkyRunner
|
|
90
90
|
job.consume!(task_args)
|
91
91
|
message.delete
|
92
92
|
rescue Exception => e
|
93
|
+
message.delete rescue nil
|
93
94
|
error_queue.push(e)
|
94
95
|
SkyRunner::log :error, "Task Failed: #{task_args} Job: #{job_id} #{e.message} #{e.backtrace.join("\n")}"
|
95
96
|
end
|
@@ -135,9 +136,12 @@ module SkyRunner
|
|
135
136
|
task_args = message_data["task_args"]
|
136
137
|
local_queue.push([klass, job_id, task_args, message])
|
137
138
|
rescue NameError => e
|
139
|
+
message.delete rescue nil
|
138
140
|
log :error, "Task Failed: No such class #{record["class"]} #{e.message}"
|
139
141
|
yield e if block_given?
|
140
142
|
end
|
143
|
+
else
|
144
|
+
message.delete
|
141
145
|
end
|
142
146
|
end
|
143
147
|
end
|