minicron 0.4 → 0.5
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.
- checksums.yaml +4 -4
- data/README.md +47 -27
- data/lib/minicron.rb +1 -5
- data/lib/minicron/cli/commands.rb +0 -1
- data/lib/minicron/constants.rb +1 -1
- data/lib/minicron/hub/app.rb +7 -1
- data/lib/minicron/hub/db/minicron.sqlite3 +0 -0
- data/lib/minicron/hub/db/schema.rb +6 -6
- data/lib/minicron/monitor.rb +9 -0
- data/spec/minicron_spec.rb +1 -5
- data/spec/valid_config.toml +6 -5
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35de796bf50cd82b589cc12e51a66b2362115a31
|
4
|
+
data.tar.gz: 62f8e00109bdbe0183cdfada35edeca291644763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0bf079a5c2d51f8c978b7e68c4b5790c4a6c1a81bc963f8d2a6955ad95947539f66209ad05678e49bcde1428a554753789ab6d7b0ceb0eeb32a15150322b87b
|
7
|
+
data.tar.gz: e353f032490d9432c5ceee70ae52068a9d9fda2bff02320436e546ffb5f4ff274fa7686d4c6dec8dd6b934ae2a1ebdba89090f460b1324b72085edd42c85d732
|
data/README.md
CHANGED
@@ -11,15 +11,15 @@ minicron
|
|
11
11
|
minicron aims to complement ````cron```` by making it easier to manage and monitor cron jobs, it can largely be
|
12
12
|
thought of as two components that interact together, the CLI and the Hub. The CLI is what is installed on your
|
13
13
|
server(s) and executes your cron command and reports the status back to the Hub. The Hub is the central point
|
14
|
-
where data from one or many instances of the CLI
|
14
|
+
where data from one or many instances of the CLI is recieved and stored in a database. The Hub also provides
|
15
15
|
a web interface to the data and makes it easy to manage your cron jobs.
|
16
16
|
|
17
|
-
- [Screenshots](#screenshots)
|
18
17
|
- [Background](#background)
|
19
18
|
- [Features](#goals)
|
20
19
|
- [Requirements](#requirements)
|
21
20
|
- [Installation](#installation)
|
22
21
|
- [Usage](#usage)
|
22
|
+
- [Security](#security)
|
23
23
|
- [Documentation](#documentation)
|
24
24
|
- [Versioning](#versioning)
|
25
25
|
- [Contributing](#contributing)
|
@@ -29,9 +29,10 @@ a web interface to the data and makes it easy to manage your cron jobs.
|
|
29
29
|
Screenshots
|
30
30
|
------------
|
31
31
|
|
32
|
-
<img src="http://f.cl.ly/items/
|
33
|
-
|
34
|
-
|
32
|
+
<img src="http://f.cl.ly/items/1k1h3n2A3Z3P3v2o0733/Image%202014-04-15%20at%2012.50.56%20am.png" height="175"/>
|
33
|
+
<img src="http://f.cl.ly/items/0c27341m2l1E230B0q1l/Image%202014-04-15%20at%2012.40.42%20am.png" height="175"/>
|
34
|
+
<img src="http://f.cl.ly/items/0Y2O0P0j012s3C3t3a3E/Image%202014-04-15%20at%2012.39.19%20am.png" height="175"/>
|
35
|
+
<img src="http://f.cl.ly/items/2R1f2m350W46423c220D/Image%202014-04-15%20at%2012.32.41%20am.png" height="175"/>
|
35
36
|
|
36
37
|
Background
|
37
38
|
-----------
|
@@ -53,7 +54,7 @@ Features
|
|
53
54
|
- SMS ([using Twilio](https://www.twilio.com))
|
54
55
|
- [PagerDuty](http://www.pagerduty.com) (SMS, Phone, Mobile Push Notifications and Email)
|
55
56
|
|
56
|
-
Lots more is planned for the future, see [open issues](issues?state=open) or if you don't see the feature you want there add it!
|
57
|
+
Lots more is planned for the future, see [open issues](https://github.com/jamesrwhite/minicron/issues?state=open) or if you don't see the feature you want there add it!
|
57
58
|
|
58
59
|
Requirements
|
59
60
|
-------------
|
@@ -66,12 +67,13 @@ Requirements
|
|
66
67
|
#### Database
|
67
68
|
|
68
69
|
- MySQL
|
69
|
-
-
|
70
|
+
- SQlite >= 3.6.16
|
71
|
+
- Support for PostgreSQL is planned in the future
|
70
72
|
|
71
73
|
#### Web Server / Reverse Proxy
|
72
74
|
|
73
75
|
If you want to run minicron behind a web server or proxy it needs to support the web socket protocol.
|
74
|
-
nginx for example supports web sockets from version 1.3.13 and up. I've included an [example config](sample.nginx.conf) for nginx.
|
76
|
+
nginx for example supports web sockets from version 1.3.13 and up. I've included an [example config](https://github.com/jamesrwhite/minicron/blob/master/sample.nginx.conf) for nginx.
|
75
77
|
|
76
78
|
#### Browser
|
77
79
|
|
@@ -92,10 +94,10 @@ but I encourage you to give it a try in a non critical environment and help me t
|
|
92
94
|
|
93
95
|
2. On some distributions you may need to install the ````ruby-dev```` and ````build-essential```` packages
|
94
96
|
|
95
|
-
3. To install the latest release (currently 0.
|
97
|
+
3. To install the latest release (currently 0.5) you can ````gem install minicron````, depending on your ruby setup
|
96
98
|
you may need to run this with ````sudo````
|
97
99
|
|
98
|
-
4. Set your database configuration options in ````/etc/minicron.toml````, you can use the [default.config.toml](default.config.toml) as a guide on what options are configurable
|
100
|
+
4. Set your database configuration options in ````/etc/minicron.toml````, you can use the [default.config.toml](https://github.com/jamesrwhite/minicron/blob/master/default.config.toml) as a guide on what options are configurable
|
99
101
|
|
100
102
|
5. Make sure you have created an empty database with the name you set in ````/etc/minicron.toml````
|
101
103
|
|
@@ -107,7 +109,7 @@ but I encourage you to give it a try in a non critical environment and help me t
|
|
107
109
|
> ````
|
108
110
|
|
109
111
|
6. You can then ````minicron db setup```` to create the database schema, alternatively you can use
|
110
|
-
the [schema dump provided](lib/minicron/hub/db/schema.sql)
|
112
|
+
the [schema dump provided](https://github.com/jamesrwhite/minicron/blob/master/lib/minicron/hub/db/schema.sql)
|
111
113
|
|
112
114
|
7. Done! See the usage section below for more details on how to use minicron now you have it installed
|
113
115
|
|
@@ -157,7 +159,7 @@ you can also use the ````stop```` and ````status```` commands to control the ser
|
|
157
159
|
To run the server in debug mode, i.e not as a daemon so you can see its output you can pass the ````--debug````
|
158
160
|
option.
|
159
161
|
|
160
|
-
See [sample.nginx.conf](sample.nginx.conf) for an example of
|
162
|
+
See [sample.nginx.conf](https://github.com/jamesrwhite/minicron/blob/master/sample.nginx.conf) for an example of
|
161
163
|
how to run minicron behind a reverse proxy.
|
162
164
|
|
163
165
|
#### Connecting to a host via SSH
|
@@ -165,8 +167,13 @@ how to run minicron behind a reverse proxy.
|
|
165
167
|
To be able to perform CRUD operations on the crontab minicron needs to connect via SSH to the host.
|
166
168
|
When you set up a host minicron automatically creates a public/private key pair for you and stores it
|
167
169
|
in ````~/.ssh```` on the host the minicron server is being run on using the naming schema ````minicron_host_*HOST_ID*_rsa(.pub)````.
|
168
|
-
To be able edit the crontab on a host minicron
|
169
|
-
|
170
|
+
To be able edit the crontab on a host minicron needs to have permission to edit ````/etc/crontab```` and write and
|
171
|
+
execute permissions on the ````/etc```` directory so it can move files there (the crontab). This will most
|
172
|
+
likely mean allowing minicron to connect to the host as the root user although you could alter your permissions
|
173
|
+
to allow for this not to be the case.
|
174
|
+
|
175
|
+
As an example, to setup minicron SSH for the root user on a host copy the public key to the hosts
|
176
|
+
authorized_keys file e.g ````/root/.ssh/authorized_keys```` on
|
170
177
|
most linux distributions or ````/var/root/.ssh/authorized_keys```` on OSX.
|
171
178
|
|
172
179
|
#### Version
|
@@ -178,15 +185,28 @@ or ````--version```` are passed to the CLI.
|
|
178
185
|
|
179
186
|
Some configuration options can be passed in manually but the recommend way to configure minicron is through the use
|
180
187
|
of a config file. You can specify the path to the file using the ````--config```` global option. The file is expected
|
181
|
-
to be in the [toml](https://github.com/mojombo/toml
|
182
|
-
[default.config.toml](
|
188
|
+
to be in the [toml](https://github.com/mojombo/toml) format. The default options are specified in the
|
189
|
+
[default.config.toml](https://github.com/jamesrwhite/minicron/blob/master/default.config.toml)
|
183
190
|
file and minicron will parse a config located in ````/etc/minicron.toml```` if it exists. Options specified via
|
184
191
|
the command line will take precedence over those taken from a config file.
|
185
192
|
|
193
|
+
Security
|
194
|
+
---------
|
195
|
+
|
196
|
+
As mentioned previously minicron is still under development and as such is missing some essential features as far as
|
197
|
+
security is concerned. For example authentication still needs to be added to the Web UI, API and Faye (the websocket
|
198
|
+
server that jobs use to communicate their status updates).
|
199
|
+
|
200
|
+
> **It is not recommended that you allow your minicron host to be accessible via the public internet!**
|
201
|
+
|
202
|
+
Obviously without authentication anyone who knew the address of your minicron host would be able to set up
|
203
|
+
a potentialyl malicious job on one of your servers! Future versions may be secure enough to expose publically but personally I still would not recommend it, minicron is designed to be an internal tool and should be behind a
|
204
|
+
firewall that only allows connections from an internal network and/or a VPN.
|
205
|
+
|
186
206
|
Documentation
|
187
207
|
-------------
|
188
208
|
|
189
|
-
minicron uses [Yard](http://yardoc.org/
|
209
|
+
minicron uses [Yard](http://yardoc.org/) for its code documentation (currently the only *usage* documentation is what you're reading right now), you can either generate it and view
|
190
210
|
it locally using the following commands:
|
191
211
|
|
192
212
|
````bash
|
@@ -194,13 +214,14 @@ yard doc
|
|
194
214
|
yard server
|
195
215
|
````
|
196
216
|
|
197
|
-
or view the most up to date version online at [RubyDoc.info](http://rdoc.info/github/jamesrwhite/minicron/master/frames
|
217
|
+
or view the most up to date version online at [RubyDoc.info](http://rdoc.info/github/jamesrwhite/minicron/master/frames).
|
198
218
|
|
199
219
|
Versioning
|
200
220
|
-----------
|
201
221
|
|
202
|
-
All stable releases will follow the [semantic versioning](http://semver.org/) guidelines. Until 1.0 hits I will try
|
203
|
-
|
222
|
+
All stable releases will follow the [semantic versioning](http://semver.org/) guidelines. Until 1.0 hits I will try
|
223
|
+
to document any breaking changes in the release descriptions but you should proceed with caution before relying
|
224
|
+
on anything etc etc
|
204
225
|
|
205
226
|
Releases will be numbered with the following format:
|
206
227
|
|
@@ -215,19 +236,18 @@ Based on the following guidelines:
|
|
215
236
|
Contributing
|
216
237
|
------------
|
217
238
|
|
218
|
-
Feedback and pull requests are welcome, please see [CONTRIBUTING.md](
|
239
|
+
Feedback and pull requests are welcome, please see [CONTRIBUTING.md](https://github.com/jamesrwhite/minicron/blob/master/CONTRIBUTING.md) for more info.
|
219
240
|
|
220
241
|
Areas that I would love some help with:
|
221
242
|
|
222
|
-
- Any of the unassigned [issues here](issues?state=open).
|
243
|
+
- Any of the unassigned [issues here](https://github.com/jamesrwhite/minicron/issues?state=open).
|
223
244
|
- General testing of the system, let me know what you think and create issues for any bugs you find!
|
224
245
|
- Tests!!
|
225
246
|
- Validation and error handling improvements
|
226
|
-
- Documentation improvements.
|
227
|
-
|
228
|
-
- Look for '[TODO:](search?q=TODO%3A)' notices littered around the code,
|
247
|
+
- Documentation improvements.
|
248
|
+
- Look for '[TODO:](https://github.com/jamesrwhite/minicron/search?q=TODO%3A)' notices littered around the code,
|
229
249
|
I'm trying to convert them all to issues but there are a lot..
|
230
|
-
- Code refactoring, I had a
|
250
|
+
- Code refactoring, I had a deadline to meet for the initial versions so some parts are a tad rushed
|
231
251
|
- UI improvements
|
232
252
|
|
233
253
|
Support
|
@@ -243,4 +263,4 @@ Or feel free to open an issue and I'll do my best to help.
|
|
243
263
|
License
|
244
264
|
--------
|
245
265
|
|
246
|
-
minicron is licensed under the GPL v3, [see here for the full license](LICENSE
|
266
|
+
minicron is licensed under the GPL v3, [see here for the full license](https://github.com/jamesrwhite/minicron/blob/master/LICENSE)
|
data/lib/minicron.rb
CHANGED
@@ -26,11 +26,7 @@ module Minicron
|
|
26
26
|
'debug' => false
|
27
27
|
},
|
28
28
|
'database' => {
|
29
|
-
'type' => '
|
30
|
-
'host' => '127.0.0.1',
|
31
|
-
'database' => 'minicron',
|
32
|
-
'username' => 'minicron',
|
33
|
-
'password' => 'password'
|
29
|
+
'type' => 'sqlite'
|
34
30
|
},
|
35
31
|
'cli' => {
|
36
32
|
'mode' => 'line',
|
@@ -162,7 +162,6 @@ module Minicron
|
|
162
162
|
yield output[:output] unless output[:type] == :status
|
163
163
|
end
|
164
164
|
rescue Exception => e
|
165
|
-
p e
|
166
165
|
# Send the exception message to the server and yield it
|
167
166
|
unless Minicron.config['cli']['dry_run']
|
168
167
|
faye.send(:job_id => ids[:job_id], :execution_id => ids[:execution_id], :type => :output, :message => e.message)
|
data/lib/minicron/constants.rb
CHANGED
data/lib/minicron/hub/app.rb
CHANGED
@@ -27,6 +27,9 @@ module Minicron::Hub
|
|
27
27
|
# Used to enable asset compression, currently nothing else
|
28
28
|
# relies on this
|
29
29
|
set :environment, :production
|
30
|
+
|
31
|
+
# Force the encoding to be UTF-8 to prevent assetpack encoding issues
|
32
|
+
Encoding.default_external = Encoding::UTF_8
|
30
33
|
end
|
31
34
|
|
32
35
|
# Configure how we server assets
|
@@ -96,7 +99,10 @@ module Minicron::Hub
|
|
96
99
|
:database => Minicron.config['database']['database'],
|
97
100
|
:username => Minicron.config['database']['username'],
|
98
101
|
:password => Minicron.config['database']['password']
|
99
|
-
|
102
|
+
when 'sqlite'
|
103
|
+
set :database,
|
104
|
+
:adapter => 'sqlite3',
|
105
|
+
:database => Minicron::HUB_PATH + '/db/minicron.sqlite3' # TODO: Allow configuring this but default to this value
|
100
106
|
else
|
101
107
|
fail Exception, "The database #{Minicron.config['database']['type']} is not supported"
|
102
108
|
end
|
Binary file
|
@@ -21,7 +21,7 @@ ActiveRecord::Schema.define(version: 0) do
|
|
21
21
|
t.datetime "sent_at", null: false
|
22
22
|
end
|
23
23
|
|
24
|
-
add_index "alerts", ["execution_id"], name: "
|
24
|
+
add_index "alerts", ["execution_id"], name: "alerts_execution_id", using: :btree
|
25
25
|
add_index "alerts", ["expected_at"], name: "expected_at", using: :btree
|
26
26
|
add_index "alerts", ["kind"], name: "kind", using: :btree
|
27
27
|
add_index "alerts", ["medium"], name: "medium", using: :btree
|
@@ -35,9 +35,9 @@ ActiveRecord::Schema.define(version: 0) do
|
|
35
35
|
t.integer "exit_status"
|
36
36
|
end
|
37
37
|
|
38
|
-
add_index "executions", ["created_at"], name: "
|
38
|
+
add_index "executions", ["created_at"], name: "executions_created_at", using: :btree
|
39
39
|
add_index "executions", ["finished_at"], name: "finished_at", using: :btree
|
40
|
-
add_index "executions", ["job_id"], name: "
|
40
|
+
add_index "executions", ["job_id"], name: "executions_job_id", using: :btree
|
41
41
|
add_index "executions", ["started_at"], name: "started_at", using: :btree
|
42
42
|
|
43
43
|
create_table "hosts", force: true do |t|
|
@@ -60,7 +60,7 @@ ActiveRecord::Schema.define(version: 0) do
|
|
60
60
|
t.datetime "timestamp", null: false
|
61
61
|
end
|
62
62
|
|
63
|
-
add_index "job_execution_outputs", ["execution_id"], name: "
|
63
|
+
add_index "job_execution_outputs", ["execution_id"], name: "job_execution_outputs_execution_id", using: :btree
|
64
64
|
add_index "job_execution_outputs", ["seq"], name: "seq", using: :btree
|
65
65
|
|
66
66
|
create_table "jobs", force: true do |t|
|
@@ -73,7 +73,7 @@ ActiveRecord::Schema.define(version: 0) do
|
|
73
73
|
t.datetime "updated_at", null: false
|
74
74
|
end
|
75
75
|
|
76
|
-
add_index "jobs", ["created_at"], name: "
|
76
|
+
add_index "jobs", ["created_at"], name: "jobs_created_at", using: :btree
|
77
77
|
add_index "jobs", ["host_id"], name: "host_id", using: :btree
|
78
78
|
add_index "jobs", ["job_hash"], name: "job_hash", unique: true, using: :btree
|
79
79
|
|
@@ -92,7 +92,7 @@ ActiveRecord::Schema.define(version: 0) do
|
|
92
92
|
add_index "schedules", ["day_of_the_month"], name: "day_of_the_month", using: :btree
|
93
93
|
add_index "schedules", ["day_of_the_week"], name: "day_of_the_week", using: :btree
|
94
94
|
add_index "schedules", ["hour"], name: "hour", using: :btree
|
95
|
-
add_index "schedules", ["job_id"], name: "
|
95
|
+
add_index "schedules", ["job_id"], name: "schedules_job_id", using: :btree
|
96
96
|
add_index "schedules", ["minute"], name: "minute", using: :btree
|
97
97
|
add_index "schedules", ["month"], name: "month", using: :btree
|
98
98
|
add_index "schedules", ["special"], name: "special", using: :btree
|
data/lib/minicron/monitor.rb
CHANGED
@@ -25,6 +25,11 @@ module Minicron
|
|
25
25
|
:username => Minicron.config['database']['username'],
|
26
26
|
:password => Minicron.config['database']['password']
|
27
27
|
)
|
28
|
+
when 'sqlite'
|
29
|
+
ActiveRecord::Base.establish_connection(
|
30
|
+
:adapter => 'sqlite3',
|
31
|
+
:database => Minicron::HUB_PATH + '/db/minicron.sqlite3' # TODO: Allow configuring this but default to this value
|
32
|
+
)
|
28
33
|
else
|
29
34
|
fail Exception, "The database #{Minicron.config['database']['type']} is not supported"
|
30
35
|
end
|
@@ -41,6 +46,10 @@ module Minicron
|
|
41
46
|
# Set the start time of the monitir
|
42
47
|
@start_time = Time.now
|
43
48
|
|
49
|
+
# Kill the thread when exceptions arne't caught so we can see the message
|
50
|
+
# TODO: should this be removed?
|
51
|
+
Thread.abort_on_exception = true
|
52
|
+
|
44
53
|
# Start a thread for the monitor
|
45
54
|
@thread = Thread.new do
|
46
55
|
# While the monitor is active run it in a loop ~every minute
|
data/spec/minicron_spec.rb
CHANGED
@@ -80,11 +80,7 @@ describe Minicron do
|
|
80
80
|
'debug' => false
|
81
81
|
},
|
82
82
|
'database' => {
|
83
|
-
'type' => '
|
84
|
-
'host' => '127.0.0.1',
|
85
|
-
'database' => 'minicron',
|
86
|
-
'username' => 'minicron',
|
87
|
-
'password' => 'password'
|
83
|
+
'type' => 'sqlite'
|
88
84
|
},
|
89
85
|
'cli' => {
|
90
86
|
'mode' => 'line',
|
data/spec/valid_config.toml
CHANGED
@@ -22,11 +22,12 @@ debug = false
|
|
22
22
|
|
23
23
|
# Database options
|
24
24
|
[database]
|
25
|
-
type = "
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
type = "sqlite" # [mysql, sqlite]
|
26
|
+
# The options below are for mysql only
|
27
|
+
# host = "127.0.0.1"
|
28
|
+
# database = "minicron"
|
29
|
+
# username = "minicron"
|
30
|
+
# password = "password"
|
30
31
|
|
31
32
|
# CLI options
|
32
33
|
[cli]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minicron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -388,6 +388,26 @@ dependencies:
|
|
388
388
|
- - '='
|
389
389
|
- !ruby/object:Gem::Version
|
390
390
|
version: 0.0.4
|
391
|
+
- !ruby/object:Gem::Dependency
|
392
|
+
name: sqlite3
|
393
|
+
requirement: !ruby/object:Gem::Requirement
|
394
|
+
requirements:
|
395
|
+
- - ~>
|
396
|
+
- !ruby/object:Gem::Version
|
397
|
+
version: '1.3'
|
398
|
+
- - '>='
|
399
|
+
- !ruby/object:Gem::Version
|
400
|
+
version: 1.3.8
|
401
|
+
type: :runtime
|
402
|
+
prerelease: false
|
403
|
+
version_requirements: !ruby/object:Gem::Requirement
|
404
|
+
requirements:
|
405
|
+
- - ~>
|
406
|
+
- !ruby/object:Gem::Version
|
407
|
+
version: '1.3'
|
408
|
+
- - '>='
|
409
|
+
- !ruby/object:Gem::Version
|
410
|
+
version: 1.3.8
|
391
411
|
- !ruby/object:Gem::Dependency
|
392
412
|
name: mysql2
|
393
413
|
requirement: !ruby/object:Gem::Requirement
|
@@ -527,6 +547,7 @@ files:
|
|
527
547
|
- lib/minicron/hub/controllers/api/jobs.rb
|
528
548
|
- lib/minicron/hub/controllers/api/schedule.rb
|
529
549
|
- lib/minicron/hub/controllers/index.rb
|
550
|
+
- lib/minicron/hub/db/minicron.sqlite3
|
530
551
|
- lib/minicron/hub/db/schema.rb
|
531
552
|
- lib/minicron/hub/db/schema.sql
|
532
553
|
- lib/minicron/hub/models/alert.rb
|