mobilize-base 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/LICENSE.txt +202 -20
- data/README.md +219 -138
- data/Rakefile +1 -2
- data/lib/mobilize-base/extensions/google_drive/acl.rb +25 -0
- data/lib/mobilize-base/extensions/google_drive/client_login_fetcher.rb +49 -0
- data/lib/mobilize-base/extensions/google_drive/file.rb +80 -0
- data/lib/mobilize-base/extensions/{google_drive.rb → google_drive/worksheet.rb} +46 -173
- data/lib/mobilize-base/extensions/resque.rb +18 -24
- data/lib/mobilize-base/extensions/string.rb +12 -0
- data/lib/mobilize-base/handlers/gbook.rb +14 -47
- data/lib/mobilize-base/handlers/gdrive.rb +17 -18
- data/lib/mobilize-base/handlers/gfile.rb +18 -39
- data/lib/mobilize-base/handlers/gridfs.rb +43 -0
- data/lib/mobilize-base/handlers/gsheet.rb +48 -99
- data/lib/mobilize-base/jobtracker.rb +29 -15
- data/lib/mobilize-base/models/dataset.rb +33 -35
- data/lib/mobilize-base/models/job.rb +21 -168
- data/lib/mobilize-base/models/runner.rb +178 -0
- data/lib/mobilize-base/models/task.rb +137 -0
- data/lib/mobilize-base/models/user.rb +47 -0
- data/lib/mobilize-base/rakes.rb +59 -0
- data/lib/mobilize-base/version.rb +1 -1
- data/lib/mobilize-base.rb +20 -9
- data/lib/samples/gdrive.yml +12 -12
- data/lib/samples/gridfs.yml +9 -0
- data/lib/samples/gsheet.yml +6 -0
- data/lib/samples/jobtracker.yml +9 -9
- data/lib/samples/mongoid.yml +3 -3
- data/mobilize-base.gemspec +1 -1
- data/test/base1_task1.yml +3 -0
- data/test/base_job_rows.yml +13 -0
- data/test/mobilize-base_test.rb +59 -0
- metadata +20 -9
- data/lib/mobilize-base/handlers/mongodb.rb +0 -32
- data/lib/mobilize-base/models/requestor.rb +0 -232
- data/lib/mobilize-base/tasks.rb +0 -43
- data/test/mobilize_test.rb +0 -108
data/.gitignore
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,20 +1,202 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
the
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright 2012 ngmoco, LLC
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
202
|
+
|
data/README.md
CHANGED
@@ -11,44 +11,53 @@ Mobilize is an end-to-end data transfer workflow manager with:
|
|
11
11
|
Mobilize-Base includes all the core scheduling and processing
|
12
12
|
functionality, allowing you to:
|
13
13
|
* put workers on the Mobilize Resque queue.
|
14
|
-
* create [
|
15
|
-
* poll for [Jobs](#section_Job) on
|
14
|
+
* create [Users](#section_Start_Users_User) and their associated Google Spreadsheet [Runners](#section_Start_Users_Runner);
|
15
|
+
* poll for [Jobs](#section_Job) on Runners (currently gsheet to gsheet only) and add them to Resque;
|
16
16
|
* monitor the status of Jobs on a rolling log.
|
17
17
|
|
18
18
|
Table Of Contents
|
19
19
|
-----------------
|
20
20
|
* [Overview](#section_Overview)
|
21
21
|
* [Install](#section_Install)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
* [Redis](#section_Install_Redis)
|
23
|
+
* [MongoDB](#section_Install_MongoDB)
|
24
|
+
* [Mobilize-Base](#section_Install_Mobilize-Base)
|
25
|
+
* [Default Folders and Files](#section_Install_Folders_and_Files)
|
26
26
|
* [Configure](#section_Configure)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
* [Google Drive](#section_Configure_Google_Drive)
|
28
|
+
* [Jobtracker](#section_Configure_Jobtracker)
|
29
|
+
* [Resque](#section_Configure_Resque)
|
30
|
+
* [Gridfs](#section_Configure_Gridfs)
|
31
|
+
* [Mongoid](#section_Configure_Mongoid)
|
31
32
|
* [Start](#section_Start)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
* [Start resque-web](#section_Start_Start_resque-web)
|
34
|
+
* [Set Environment](#section_Start_Set_Environment)
|
35
|
+
* [Create User](#section_Start_Create_User)
|
36
|
+
* [Start Workers](#section_Start_Start_Workers)
|
37
|
+
* [View Logs](#section_Start_View_Logs)
|
38
|
+
* [Start Jobtracker](#section_Start_Start_Jobtracker)
|
39
|
+
* [Create Job](#section_Start_Create_Job)
|
40
|
+
* [Run Test](#section_Start_Run_Test)
|
41
|
+
* [Add Gbooks and Gsheets](#section_Start_Add_Gbooks_And_Gsheets)
|
40
42
|
* [Meta](#section_Meta)
|
41
43
|
* [Author](#section_Author)
|
44
|
+
* [Special Thanks](#section_Special_Thanks)
|
45
|
+
|
42
46
|
|
43
47
|
<a name='section_Overview'></a>
|
44
48
|
Overview
|
45
49
|
-----------
|
46
50
|
|
47
|
-
* Mobilize is a
|
48
|
-
|
49
|
-
*
|
50
|
-
|
51
|
-
|
51
|
+
* Mobilize is a script deployment and data visualization framework with
|
52
|
+
a Google Spreadsheets UI.
|
53
|
+
* Mobilize uses Resque for parallelization and queueuing, MongoDB for caching,
|
54
|
+
and Google Drive for hosting, user input and display.
|
55
|
+
* The [mobilize-ssh][mobilize-ssh] gem allows you to run scripts and
|
56
|
+
copy files between different machines, and have output directed to a
|
57
|
+
spreadsheet for viewing and processing.
|
58
|
+
* The platform is easily extensible: add your own rake tasks and
|
59
|
+
handlers by following a few simple conventions, and you can have your own
|
60
|
+
Mobilize gem up and running in no time.
|
52
61
|
|
53
62
|
<a name='section_Install'></a>
|
54
63
|
Install
|
@@ -70,7 +79,7 @@ instructions.
|
|
70
79
|
### MongoDB
|
71
80
|
|
72
81
|
MongoDB is used to persist caches between reads and writes, keep track
|
73
|
-
of
|
82
|
+
of Users and Jobs, and store Datasets that map to endpoints.
|
74
83
|
|
75
84
|
Please refer to the [MongoDB Quickstart Page][mongodb_quickstart] to get started.
|
76
85
|
|
@@ -110,21 +119,25 @@ same one that contains your Rakefile)
|
|
110
119
|
Inside the Rakefile in your project's root folder, make sure you have:
|
111
120
|
|
112
121
|
``` ruby
|
113
|
-
require 'mobilize-base/
|
122
|
+
require 'mobilize-base/rakes'
|
114
123
|
```
|
115
124
|
|
116
|
-
This defines tasks essential to run the environment.
|
125
|
+
This defines rake tasks essential to run the environment.
|
117
126
|
|
118
127
|
### Config and Log Folders
|
119
128
|
|
120
129
|
run
|
121
130
|
|
122
|
-
$ rake
|
131
|
+
$ rake mobilize_base:setup
|
132
|
+
|
133
|
+
Mobilize will create config/mobilize/ and log/ folders at the project root
|
134
|
+
level. (same as the Rakefile).
|
123
135
|
|
124
|
-
|
125
|
-
|
136
|
+
(You can override these by passing
|
137
|
+
MOBILIZE_CONFIG_DIR and/or MOBILIZE_LOG_DIR arguments to the command.
|
138
|
+
All directories must end with a '/'.)
|
126
139
|
|
127
|
-
|
140
|
+
The script will also create samples for all required config files, which are detailed below.
|
128
141
|
|
129
142
|
Resque will create a mobilize-resque-`<environment>`.log in the log folder,
|
130
143
|
and loop over 10 files, 10MB each.
|
@@ -133,66 +146,71 @@ and loop over 10 files, 10MB each.
|
|
133
146
|
Configure
|
134
147
|
------------
|
135
148
|
|
136
|
-
All Mobilize configurations live in files in `config/*.yml
|
149
|
+
All Mobilize configurations live in files in `config/mobilize/*.yml` by
|
150
|
+
default. Samples can
|
137
151
|
be found below or on github in the [lib/samples][git_samples] folder.
|
138
152
|
|
139
153
|
<a name='section_Configure_Google_Drive'></a>
|
140
154
|
### Configure Google Drive
|
141
155
|
|
142
|
-
|
143
|
-
*
|
156
|
+
gdrive.yml needs:
|
157
|
+
* a domain, which can be gmail.com but may be different depending on
|
158
|
+
your organization. All gdrive accounts should have
|
159
|
+
the same domain, and all Users should have emails in this domain.
|
160
|
+
* an owner name and password. You can set up separate owners
|
144
161
|
for different environments as in the below file, which will keep your
|
145
162
|
mission critical workers from getting rate-limit errors.
|
146
163
|
* one or more admins with email attributes -- these will be for people
|
147
|
-
who should be given write permissions to
|
148
|
-
maintenance purposes.
|
149
|
-
* one or more workers with
|
164
|
+
who should be given write permissions to all Mobilize books in the
|
165
|
+
environment for maintenance purposes.
|
166
|
+
* one or more workers with name and pw attributes -- they will be used
|
150
167
|
to queue up google reads and writes. This can be the same as the owner
|
151
168
|
account for testing purposes or low-volume environments.
|
152
169
|
|
153
170
|
__Mobilize only allows one Resque
|
154
171
|
worker at a time to use a Google drive worker account for
|
155
|
-
reading/writing.__
|
172
|
+
reading/writing, which is called a gdrive_slot.__
|
156
173
|
|
157
174
|
Sample gdrive.yml:
|
158
175
|
|
159
176
|
``` yml
|
160
|
-
|
161
177
|
development:
|
178
|
+
domain: 'host.com'
|
162
179
|
owner:
|
163
|
-
|
180
|
+
name: 'owner_development'
|
164
181
|
pw: "google_drive_password"
|
165
182
|
admins:
|
166
|
-
- {
|
183
|
+
- {name: 'admin'}
|
167
184
|
workers:
|
168
|
-
- {
|
169
|
-
- {
|
185
|
+
- {name: 'worker_development001', pw: "worker001_google_drive_password"}
|
186
|
+
- {name: 'worker_development002', pw: "worker002_google_drive_password"}
|
170
187
|
test:
|
188
|
+
domain: 'host.com'
|
171
189
|
owner:
|
172
|
-
|
190
|
+
name: 'owner_test'
|
173
191
|
pw: "google_drive_password"
|
174
192
|
admins:
|
175
|
-
- {
|
193
|
+
- {name: 'admin'}
|
176
194
|
workers:
|
177
|
-
- {
|
178
|
-
- {
|
195
|
+
- {name: 'worker_test001', pw: "worker001_google_drive_password"}
|
196
|
+
- {name: 'worker_test002', pw: "worker002_google_drive_password"}
|
179
197
|
production:
|
198
|
+
domain: 'host.com'
|
180
199
|
owner:
|
181
|
-
|
200
|
+
name: 'owner_production'
|
182
201
|
pw: "google_drive_password"
|
183
202
|
admins:
|
184
|
-
- {
|
203
|
+
- {name: 'admin'}
|
185
204
|
workers:
|
186
|
-
- {
|
187
|
-
- {
|
188
|
-
|
205
|
+
- {name: 'worker_production001', pw: "worker001_google_drive_password"}
|
206
|
+
- {name: 'worker_production002', pw: "worker002_google_drive_password"}
|
189
207
|
```
|
190
208
|
|
191
209
|
<a name='section_Configure_Jobtracker'></a>
|
192
210
|
### Configure Jobtracker
|
193
211
|
|
194
212
|
The Jobtracker sits on your Resque and does 2 things:
|
195
|
-
* check for
|
213
|
+
* check for Users that are due for polling;
|
196
214
|
* send out notifications when:
|
197
215
|
* there are failed jobs on Resque;
|
198
216
|
* there are jobs on Resque that have run beyond the max run time.
|
@@ -205,27 +223,83 @@ below and in the [lib/samples][git_samples] folder:
|
|
205
223
|
|
206
224
|
``` yml
|
207
225
|
development:
|
208
|
-
cycle_freq: 10 #
|
226
|
+
cycle_freq: 10 #time between Jobtracker sweeps
|
209
227
|
notification_freq: 3600 #1 hour between failure/timeout notifications
|
210
|
-
|
228
|
+
runner_read_freq: 300 #5 min between runner reads
|
211
229
|
max_run_time: 14400 # if a job runs for 4h+, notification will be sent
|
230
|
+
extensions: [] #additional Mobilize modules to load workers with
|
212
231
|
admins: #emails to send notifications to
|
213
|
-
|
232
|
+
- {'email': 'admin@host.com'}
|
214
233
|
test:
|
215
|
-
cycle_freq: 10 #
|
234
|
+
cycle_freq: 10 #time between Jobtracker sweeps
|
216
235
|
notification_freq: 3600 #1 hour between failure/timeout notifications
|
217
|
-
|
236
|
+
runner_read_freq: 300 #5 min between runner reads
|
218
237
|
max_run_time: 14400 # if a job runs for 4h+, notification will be sent
|
238
|
+
extensions: [] #additional Mobilize modules to load workers with
|
219
239
|
admins: #emails to send notifications to
|
220
|
-
|
221
|
-
|
240
|
+
- {'email': 'admin@host.com'}
|
222
241
|
production:
|
223
|
-
cycle_freq: 10 #
|
242
|
+
cycle_freq: 10 #time between Jobtracker sweeps
|
224
243
|
notification_freq: 3600 #1 hour between failure/timeout notifications
|
225
|
-
|
244
|
+
runner_read_freq: 300 #5 min between runner reads
|
226
245
|
max_run_time: 14400 # if a job runs for 4h+, notification will be sent
|
246
|
+
extensions: [] #additional Mobilize modules to load workers with
|
227
247
|
admins: #emails to send notifications to
|
228
|
-
|
248
|
+
- {'email': 'admin@host.com'}
|
249
|
+
```
|
250
|
+
|
251
|
+
<a name='section_Configure_Resque'></a>
|
252
|
+
### Configure Resque
|
253
|
+
|
254
|
+
Resque keeps track of Jobs, Workers and logging.
|
255
|
+
|
256
|
+
It needs the below parameters, which can be found in the [lib/samples][git_samples] folder.
|
257
|
+
|
258
|
+
* queue_name - the name of the Resque queue where you would like the Jobtracker and Resque Workers to
|
259
|
+
run. Default is mobilize.
|
260
|
+
* max_workers - the total number of simultaneous workers you would like
|
261
|
+
on your queue. Default is 4 for development and test, 36 in
|
262
|
+
production, but feel free to adjust depending on your hardware.
|
263
|
+
* redis_port - you should probably leave this alone, it specifies the
|
264
|
+
default port for dev and prod and a separate one for testing.
|
265
|
+
|
266
|
+
``` yml
|
267
|
+
development:
|
268
|
+
queue_name: 'mobilize'
|
269
|
+
max_workers: 4
|
270
|
+
redis_port: 6379
|
271
|
+
test:
|
272
|
+
queue_name: 'mobilize'
|
273
|
+
max_workers: 4
|
274
|
+
redis_port: 9736
|
275
|
+
production:
|
276
|
+
queue_name: 'mobilize'
|
277
|
+
max_workers: 36
|
278
|
+
redis_port: 6379
|
279
|
+
```
|
280
|
+
|
281
|
+
<a name='section_Configure_Gridfs'></a>
|
282
|
+
### Configure Gridfs
|
283
|
+
|
284
|
+
Mobilize stores cached data in MongoDB Gridfs.
|
285
|
+
It needs the below parameters, which can be found in the [lib/samples][git_samples] folder.
|
286
|
+
|
287
|
+
* max_versions - the number of __different__ versions of data to keep
|
288
|
+
for a given cache. Default is 10. This is meant mostly to allow you to
|
289
|
+
restore Runners from cache if necessary.
|
290
|
+
* max_compressed_write_size - the amount of compressed data Gridfs will
|
291
|
+
allow. If you try to write more than this, an exception will be thrown.
|
292
|
+
|
293
|
+
``` yml
|
294
|
+
development:
|
295
|
+
max_versions: 10 #number of versions of cache to keep in gridfs
|
296
|
+
max_compressed_write_size: 1000000000 #~1GB
|
297
|
+
test:
|
298
|
+
max_versions: 10 #number of versions of cache to keep in gridfs
|
299
|
+
max_compressed_write_size: 1000000000 #~1GB
|
300
|
+
production:
|
301
|
+
max_versions: 10 #number of versions of cache to keep in gridfs
|
302
|
+
max_compressed_write_size: 1000000000 #~1GB
|
229
303
|
```
|
230
304
|
|
231
305
|
<a name='section_Configure_Mongoid'></a>
|
@@ -262,36 +336,6 @@ production:
|
|
262
336
|
- 127.0.0.1:27017
|
263
337
|
```
|
264
338
|
|
265
|
-
<a name='section_Configure_Resque'></a>
|
266
|
-
### Configure Resque
|
267
|
-
|
268
|
-
Resque keeps track of Jobs, Workers and logging.
|
269
|
-
|
270
|
-
It needs the below parameters, which can be found in the [lib/samples][git_samples] folder.
|
271
|
-
|
272
|
-
* queue_name - the name of the Resque queue where you would like the Jobtracker and Resque Workers to
|
273
|
-
run. Default is mobilize.
|
274
|
-
* max_workers - the total number of simultaneous workers you would like
|
275
|
-
on your queue. Default is 4 for development and test, 36 in
|
276
|
-
production, but feel free to adjust depending on your hardware.
|
277
|
-
* redis_port - you should probably leave this alone, it specifies the
|
278
|
-
default port for dev and prod and a separate one for testing.
|
279
|
-
|
280
|
-
``` yml
|
281
|
-
development:
|
282
|
-
queue_name: 'mobilize'
|
283
|
-
max_workers: 4
|
284
|
-
redis_port: 6379
|
285
|
-
test:
|
286
|
-
queue_name: 'mobilize'
|
287
|
-
max_workers: 4
|
288
|
-
redis_port: 9736
|
289
|
-
production:
|
290
|
-
queue_name: 'mobilize'
|
291
|
-
max_workers: 36
|
292
|
-
redis_port: 6379
|
293
|
-
```
|
294
|
-
|
295
339
|
<a name='section_Start'></a>
|
296
340
|
Start
|
297
341
|
-----
|
@@ -300,8 +344,8 @@ A Mobilize instance can be considered "started" or "running" when you have:
|
|
300
344
|
|
301
345
|
1. Resque workers running on the Mobilize queue;
|
302
346
|
2. A Jobtracker running on one of the Resque workers;
|
303
|
-
3. One or more
|
304
|
-
4. One or more Jobs created in a
|
347
|
+
3. One or more Users created in your MongoDB;
|
348
|
+
4. One or more Jobs created in a User's Runner;
|
305
349
|
|
306
350
|
<a name='section_Start_Start_resque-web'></a>
|
307
351
|
### Start resque-web
|
@@ -339,26 +383,26 @@ Otherwise, it takes it from MOBILIZE_ENV parameter, set from irb, as in:
|
|
339
383
|
This affects all parameters as set in the yml files, including the
|
340
384
|
database.
|
341
385
|
|
342
|
-
<a name='
|
343
|
-
### Create
|
386
|
+
<a name='section_Start_Create_User'></a>
|
387
|
+
### Create User
|
344
388
|
|
345
|
-
|
346
|
-
endpoint to another. They each have a
|
389
|
+
Users are people who use the Mobilize service to move data from one
|
390
|
+
endpoint to another. They each have a Runner, which is a google sheet
|
347
391
|
that contains one or more Jobs.
|
348
392
|
|
349
|
-
To create a requestor, use the
|
350
|
-
command
|
351
|
-
|
393
|
+
To create a requestor, use the User.find_or_create_by_name
|
394
|
+
command (replace the user with your own name, or any name
|
395
|
+
in your domain).
|
352
396
|
|
353
397
|
``` ruby
|
354
|
-
>
|
398
|
+
irb> User.find_or_create_by_name("user_name")
|
355
399
|
```
|
356
400
|
|
357
401
|
<a name='section_Start_Start_Workers'></a>
|
358
402
|
### Start Workers
|
359
403
|
|
360
404
|
Workers are rake tasks that load the Mobilize environment and allow the
|
361
|
-
processing of the Jobtracker,
|
405
|
+
processing of the Jobtracker, Users and Jobs.
|
362
406
|
|
363
407
|
These will start as many workers as are defined in your resque.yml.
|
364
408
|
|
@@ -375,13 +419,13 @@ them, do:
|
|
375
419
|
> Jobtracker.restart_workers!
|
376
420
|
```
|
377
421
|
|
378
|
-
Note that
|
422
|
+
Note that restart will kill any workers on the Mobilize queue.
|
379
423
|
|
380
424
|
<a name='section_Start_View_Logs'></a>
|
381
425
|
### View Logs
|
382
426
|
|
383
427
|
at this point, you'll want to start viewing the logs for the Resque
|
384
|
-
workers -- they will be stored under your log folder
|
428
|
+
workers -- they will be stored under your log folder, by default log/. You can do:
|
385
429
|
|
386
430
|
$ tail -f log/mobilize-`<environment>`.log
|
387
431
|
|
@@ -390,35 +434,35 @@ to view them.
|
|
390
434
|
<a name='section_Start_Start_Jobtracker'></a>
|
391
435
|
### Start Jobtracker
|
392
436
|
|
393
|
-
Once the Resque workers are running, and you have at least one
|
437
|
+
Once the Resque workers are running, and you have at least one User
|
394
438
|
set up, it's time to start the Jobtracker:
|
395
439
|
|
396
440
|
``` ruby
|
397
441
|
> Jobtracker.start
|
398
442
|
```
|
399
443
|
|
400
|
-
The Jobtracker will automatically enqueue any
|
444
|
+
The Jobtracker will automatically enqueue any Users that have not
|
401
445
|
been processed in the requestor_refresh period defined in the
|
402
|
-
jobtracker.yml, and create their
|
446
|
+
jobtracker.yml, and create their Runners if they do not exist. You can
|
403
447
|
see this process on your Resque UI and in the log file.
|
404
448
|
|
405
449
|
<a name='section_Start_Create_Job'></a>
|
406
450
|
### Create Job
|
407
451
|
|
408
|
-
Now it's time to go onto the
|
452
|
+
Now it's time to go onto the Runner and add a Job to be processed.
|
409
453
|
|
410
454
|
To do this, you should log into your Google Drive with either the
|
411
|
-
owner's account, an admin account, or the
|
412
|
-
will be the accounts with edit permissions to a given
|
455
|
+
owner's account, an admin account, or the Runner User's account. These
|
456
|
+
will be the accounts with edit permissions to a given Runner.
|
413
457
|
|
414
|
-
Navigate to the Jobs tab on the
|
415
|
-
name>)` and enter values under each header:
|
458
|
+
Navigate to the Jobs tab on the Runner `(denoted by Runner(<requestor
|
459
|
+
name>))` and enter values under each header:
|
416
460
|
|
417
461
|
* name This is the name of the job you would like to add. Names must be unique across all your jobs, otherwise you will get an error
|
418
462
|
|
419
463
|
* active set this to blank or FALSE if you want to turn off a job
|
420
464
|
|
421
|
-
*
|
465
|
+
* trigger This uses human readable syntax to schedule jobs. It accepts the following:
|
422
466
|
* every `<integer>` hour -- fire the job at increments of `<integer>` hours, minimum of 1 hour
|
423
467
|
* every `<integer>` day -- fire the job at increments of `<integer>` days, minimum of 1
|
424
468
|
* every `<integer>` day after <HH:MM> -- fire the job at increments of <integer> days, after HH:MM UTC time
|
@@ -429,32 +473,47 @@ name>)` and enter values under each header:
|
|
429
473
|
|
430
474
|
* status Mobilize writes this field with the last status returned by the job
|
431
475
|
|
432
|
-
*
|
433
|
-
|
476
|
+
* task1..task5 List of tasks to be performed by the job.
|
477
|
+
* Tasks have this syntax: <handler>.<call> <params>.
|
478
|
+
* handler specifies the file that should receive the task
|
479
|
+
* the call specifies the method within the file. The method should
|
480
|
+
be called `"<Handler>.<call>_by_task_path"`
|
481
|
+
* the params the method accepts, which are custom to each
|
482
|
+
task. These should be a comma-delimited list, with each param in
|
483
|
+
quotes.
|
484
|
+
* For mobilize-base, the following tasks are available:
|
485
|
+
* gsheet.read `<input_gsheet_full_path>`, which reads the sheet.
|
486
|
+
* The gsheet_path should be of the form `<gbook_name>/<gsheet_name>`. The test uses
|
487
|
+
"Requestor_mobilize(test)/base1_task1.in".
|
488
|
+
* gsheet.write `<task_relative_path>`,`<output_gsheet_path>`,
|
489
|
+
which writes the specified task output to the output_gsheet.
|
490
|
+
* The task_path should be of the form `<task_column>` or
|
491
|
+
`<job_name/task_column>`. The test uses "base1/task1" for the first test
|
492
|
+
and simply "task1" for the second test. Both of these take the output
|
493
|
+
from the first task.
|
494
|
+
* The test uses "Requestor_mobilize(test)/base1.out" and
|
495
|
+
"Requestor_mobilize(test)/base2.out" for output sheets.
|
434
496
|
|
435
|
-
|
436
|
-
|
437
|
-
* read_handler This is where the job reads its data from. For
|
438
|
-
mobilize-base, you should enter "gsheet"
|
497
|
+
<a name='section_Start_Run_Test'></a>
|
498
|
+
### Run Test
|
439
499
|
|
440
|
-
|
441
|
-
mobilize-base, you should enter "gsheet"
|
500
|
+
To run tests, you will need to
|
442
501
|
|
443
|
-
|
444
|
-
which can be used for parameters.
|
445
|
-
The format is `<google docs book>/<google docs sheet>`, so if you
|
446
|
-
wanted to read from the "output" sheet on the "monthly_results" book you
|
447
|
-
would write in `monthly_results/output`. For a sheet in the Jobspec
|
448
|
-
itself you could write simply `<output>`.
|
502
|
+
1) clone the repository
|
449
503
|
|
450
|
-
|
451
|
-
for parameters.
|
504
|
+
From the project folder, run
|
452
505
|
|
453
|
-
|
454
|
-
For a gsheet write_handler, this would be the name of the sheet to be
|
455
|
-
written to, similar to param_sheets.
|
506
|
+
2) rake mobilize_base:setup
|
456
507
|
|
457
|
-
|
508
|
+
and populate the "test" environment in the config files with the
|
509
|
+
necessary details.
|
510
|
+
|
511
|
+
3) $ rake test
|
512
|
+
|
513
|
+
This will create a test Runner with a sample job. These will run off a
|
514
|
+
test redis instance which will be killed once the tests finish.
|
515
|
+
|
516
|
+
<a name='section_Start_'></a>
|
458
517
|
### Run Test
|
459
518
|
|
460
519
|
To run tests, you will need to
|
@@ -463,15 +522,34 @@ To run tests, you will need to
|
|
463
522
|
|
464
523
|
From the project folder, run
|
465
524
|
|
466
|
-
2) rake
|
525
|
+
2) rake mobilize_base:setup
|
467
526
|
|
468
527
|
and populate the "test" environment in the config files with the
|
469
528
|
necessary details.
|
470
529
|
|
471
530
|
3) $ rake test
|
472
531
|
|
473
|
-
This will create a test
|
474
|
-
test redis instance
|
532
|
+
This will create a test Runner with a sample job. These will run off a
|
533
|
+
test redis instance. This instance will be kept alive so you can test
|
534
|
+
additional Mobilize modules. (see [mobilize-ssh][mobilize-ssh] for more)
|
535
|
+
|
536
|
+
<a name='section_Start_Add_Gbooks_And_Gsheets'></a>
|
537
|
+
### Add Gbooks and Gsheets
|
538
|
+
|
539
|
+
A User's Runner should be kept clean, preferably with only the jobs
|
540
|
+
sheet. The test keeps everything in the
|
541
|
+
Runner, but in reality you will want to create lots of different books
|
542
|
+
to share with different people in your organization.
|
543
|
+
|
544
|
+
To add a new Gbook, create one as you normally would, then make sure the
|
545
|
+
Owner is the same user as specified in your gdrive.yml/owner/name value.
|
546
|
+
Mobilize will handle the rest, extending permissions to workers and
|
547
|
+
admins.
|
548
|
+
|
549
|
+
Also make sure any Gsheets you specify for __read__ operations exist
|
550
|
+
prior to calling the job, or there will be an error. __Write__
|
551
|
+
operations will create the book and sheet if it does not already exist,
|
552
|
+
already under ownership of the owner account.
|
475
553
|
|
476
554
|
<a name='section_Meta'></a>
|
477
555
|
Meta
|
@@ -479,7 +557,7 @@ Meta
|
|
479
557
|
|
480
558
|
* Code: `git clone git://github.com/ngmoco/mobilize-base.git`
|
481
559
|
* Home: <https://github.com/ngmoco/mobilize-base>
|
482
|
-
* Bugs: <https://github.com
|
560
|
+
* Bugs: <https://github.com/ngmoco/mobilize-base/issues>
|
483
561
|
* Gems: <http://rubygems.org/gems/mobilize-base>
|
484
562
|
|
485
563
|
<a name='section_Author'></a>
|
@@ -498,6 +576,8 @@ Special Thanks
|
|
498
576
|
reinvent the wheel
|
499
577
|
* ngmoco:) and DeNA Global for supporting and adopting the Mobilize
|
500
578
|
platform
|
579
|
+
* gimite, defunkt, 10gen, and the countless other github heroes and
|
580
|
+
crewmembers.
|
501
581
|
|
502
582
|
[google_drive_ruby]: https://github.com/gimite/google-drive-ruby
|
503
583
|
[resque]: https://github.com/defunkt/resque
|
@@ -507,3 +587,4 @@ platform
|
|
507
587
|
[git_samples]: https://github.ngmoco.com/Ngpipes/mobilize-base/tree/master/lib/samples
|
508
588
|
[rvm]: https://rvm.io/
|
509
589
|
[resque-web]: https://github.com/defunkt/resque#standalone
|
590
|
+
[mobilize-ssh]: https://github.com/ngmoco/mobilize-ssh
|