minicron 0.1.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +96 -43
- data/Rakefile +9 -1
- data/lib/minicron.rb +9 -4
- data/lib/minicron/alert.rb +2 -1
- data/lib/minicron/alert/email.rb +7 -2
- data/lib/minicron/alert/pagerduty.rb +3 -2
- data/lib/minicron/alert/sms.rb +2 -1
- data/lib/minicron/cli.rb +49 -19
- data/lib/minicron/constants.rb +2 -1
- data/lib/minicron/cron.rb +6 -6
- data/lib/minicron/hub/app.rb +8 -8
- data/lib/minicron/hub/assets/app/controllers/executions.js +4 -3
- data/lib/minicron/hub/assets/app/controllers/hosts.js +4 -4
- data/lib/minicron/hub/assets/app/controllers/jobs.js +4 -4
- data/lib/minicron/hub/assets/app/controllers/schedules.js +4 -1
- data/lib/minicron/hub/controllers/api/executions.rb +4 -4
- data/lib/minicron/hub/controllers/api/hosts.rb +18 -5
- data/lib/minicron/hub/controllers/api/job_execution_outputs.rb +2 -2
- data/lib/minicron/hub/controllers/api/jobs.rb +8 -8
- data/lib/minicron/hub/controllers/api/schedule.rb +10 -10
- data/lib/minicron/hub/db/schema.rb +70 -65
- data/lib/minicron/hub/db/schema.sql +53 -25
- data/lib/minicron/hub/models/execution.rb +1 -1
- data/lib/minicron/hub/models/host.rb +10 -1
- data/lib/minicron/hub/models/job.rb +3 -3
- data/lib/minicron/hub/models/schedule.rb +1 -1
- data/lib/minicron/hub/serializers/execution.rb +61 -57
- data/lib/minicron/hub/serializers/host.rb +49 -42
- data/lib/minicron/hub/serializers/job.rb +82 -78
- data/lib/minicron/hub/serializers/job_execution_output.rb +42 -38
- data/lib/minicron/hub/serializers/schedule.rb +56 -52
- data/lib/minicron/hub/views/handlebars/executions.erb +7 -1
- data/lib/minicron/hub/views/handlebars/hosts.erb +2 -2
- data/lib/minicron/hub/views/handlebars/schedules.erb +3 -3
- data/lib/minicron/monitor.rb +4 -4
- data/lib/minicron/transport/client.rb +6 -6
- data/lib/minicron/transport/faye/client.rb +4 -4
- data/lib/minicron/transport/faye/extensions/job_handler.rb +3 -2
- data/lib/minicron/transport/faye/server.rb +1 -0
- data/lib/minicron/transport/server.rb +2 -2
- data/lib/minicron/transport/ssh.rb +6 -8
- data/spec/minicron/cli_spec.rb +4 -4
- data/spec/minicron/transport/client_spec.rb +2 -2
- data/spec/minicron/transport/faye/client_spec.rb +7 -7
- data/spec/minicron/transport/server_spec.rb +1 -1
- data/spec/minicron_spec.rb +2 -1
- data/spec/valid_config.toml +1 -0
- metadata +16 -2
@@ -1,104 +1,108 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Minicron
|
2
|
+
module Hub
|
3
|
+
class JobSerializer
|
4
|
+
def initialize(jobs)
|
5
|
+
@jobs = jobs
|
6
|
+
end
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
def serialize
|
9
|
+
@response = {
|
10
|
+
:jobs => [],
|
11
|
+
:hosts => [],
|
12
|
+
:executions => [],
|
13
|
+
:schedules => []
|
14
|
+
}
|
15
|
+
|
16
|
+
if @jobs.respond_to? :each
|
17
|
+
@jobs.each do |job|
|
18
|
+
do_serialization(job)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
do_serialization(@jobs)
|
22
|
+
end
|
23
|
+
|
24
|
+
@response
|
17
25
|
end
|
18
|
-
else
|
19
|
-
do_serialization(@jobs)
|
20
|
-
end
|
21
26
|
|
22
|
-
|
23
|
-
|
27
|
+
def do_serialization(job)
|
28
|
+
new_job = {}
|
24
29
|
|
25
|
-
|
26
|
-
|
30
|
+
# Add all the normal attributes of the job
|
31
|
+
job.attributes.each do |key, value|
|
32
|
+
# To make our name method in the model work :/
|
33
|
+
value = job.name if key == 'name'
|
27
34
|
|
28
|
-
|
29
|
-
|
30
|
-
# To make our name method in the model work :/
|
31
|
-
value = job.name if key == 'name'
|
35
|
+
# Remove _id from keys
|
36
|
+
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
32
37
|
|
33
|
-
|
34
|
-
|
38
|
+
new_job[key] = value
|
39
|
+
end
|
35
40
|
|
36
|
-
|
37
|
-
|
41
|
+
# Set up the execution ids array
|
42
|
+
new_job[:executions] = []
|
38
43
|
|
39
|
-
|
40
|
-
|
44
|
+
# Set up the schedules ids array
|
45
|
+
new_job[:schedules] = []
|
41
46
|
|
42
|
-
|
43
|
-
|
47
|
+
# Add the host to the sideloaded data
|
48
|
+
new_host = {}
|
49
|
+
job.host.attributes.each do |key, value|
|
50
|
+
# To make our name method in the model work :/
|
51
|
+
value = job.host.name if key == 'name'
|
44
52
|
|
45
|
-
|
46
|
-
|
47
|
-
job.host.attributes.each do |key, value|
|
48
|
-
# To make our name method in the model work :/
|
49
|
-
value = job.host.name if key == 'name'
|
53
|
+
# Remove _id from keys
|
54
|
+
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
50
55
|
|
51
|
-
|
52
|
-
|
56
|
+
new_host[key] = value
|
57
|
+
end
|
53
58
|
|
54
|
-
|
55
|
-
|
59
|
+
# Append the new host to the @response
|
60
|
+
@response[:hosts].push(new_host)
|
56
61
|
|
57
|
-
|
58
|
-
|
62
|
+
# Add the schedules to the sideloaded data and the ids to
|
63
|
+
# the job
|
64
|
+
job.schedules.each do |schedule|
|
65
|
+
new_schedule = {}
|
59
66
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
new_schedule = {}
|
67
|
+
schedule.attributes.each do |key, value|
|
68
|
+
# Remove _id from keys
|
69
|
+
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
71
|
+
new_schedule[key] = value
|
72
|
+
end
|
68
73
|
|
69
|
-
|
70
|
-
|
74
|
+
# Add the formatted version of the schedule
|
75
|
+
new_schedule['formatted'] = schedule.formatted
|
71
76
|
|
72
|
-
|
73
|
-
|
77
|
+
@response[:schedules].push(new_schedule)
|
78
|
+
new_job[:schedules].push(schedule.id)
|
79
|
+
end
|
74
80
|
|
75
|
-
|
76
|
-
|
77
|
-
|
81
|
+
# Add the executions to the sideloaded data and the ids to
|
82
|
+
# the job
|
83
|
+
job.executions.each do |execution|
|
84
|
+
new_execution = {}
|
78
85
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
new_execution = {}
|
86
|
+
execution.attributes.each do |key, value|
|
87
|
+
# Remove _id from keys
|
88
|
+
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
83
89
|
|
84
|
-
|
85
|
-
|
86
|
-
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
90
|
+
new_execution[key] = value
|
91
|
+
end
|
87
92
|
|
88
|
-
|
89
|
-
|
93
|
+
# Also we need to add the job execution output ids
|
94
|
+
new_execution[:job_execution_outputs] = []
|
95
|
+
execution.job_execution_outputs.each do |job_execution_output|
|
96
|
+
new_execution[:job_execution_outputs].push(job_execution_output.id)
|
97
|
+
end
|
90
98
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
new_execution[:job_execution_outputs].push(job_execution_output.id)
|
95
|
-
end
|
99
|
+
@response[:executions].push(new_execution)
|
100
|
+
new_job[:executions].push(execution.id)
|
101
|
+
end
|
96
102
|
|
97
|
-
|
98
|
-
|
103
|
+
# Append the new job to the @responseh
|
104
|
+
@response[:jobs].push(new_job)
|
105
|
+
end
|
99
106
|
end
|
100
|
-
|
101
|
-
# Append the new job to the @responseh
|
102
|
-
@response[:jobs].push(new_job)
|
103
107
|
end
|
104
108
|
end
|
@@ -1,48 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def serialize
|
7
|
-
@response = {
|
8
|
-
:job_execution_outputs => [],
|
9
|
-
:executions => []
|
10
|
-
}
|
11
|
-
|
12
|
-
if @job_execution_outputs.respond_to? :each
|
13
|
-
@job_execution_outputs.each do |job_execution_output|
|
14
|
-
do_serialization(job_execution_output)
|
1
|
+
module Minicron
|
2
|
+
module Hub
|
3
|
+
class JobExecutionOutputSerializer
|
4
|
+
def initialize(job_execution_outputs)
|
5
|
+
@job_execution_outputs = job_execution_outputs
|
15
6
|
end
|
16
|
-
else
|
17
|
-
do_serialization(@job_execution_outputs)
|
18
|
-
end
|
19
7
|
|
20
|
-
|
21
|
-
|
8
|
+
def serialize
|
9
|
+
@response = {
|
10
|
+
:job_execution_outputs => [],
|
11
|
+
:executions => []
|
12
|
+
}
|
13
|
+
|
14
|
+
if @job_execution_outputs.respond_to? :each
|
15
|
+
@job_execution_outputs.each do |job_execution_output|
|
16
|
+
do_serialization(job_execution_output)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
do_serialization(@job_execution_outputs)
|
20
|
+
end
|
21
|
+
|
22
|
+
@response
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
def do_serialization(job_execution_output)
|
26
|
+
new_job_execution_output = {}
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
# Add all the normal attributes of the job_execution_output
|
29
|
+
job_execution_output.attributes.each do |key, value|
|
30
|
+
# Remove _id from keys
|
31
|
+
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
32
|
+
new_job_execution_output[key] = value
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
# Add the execution to the sideloaded data
|
36
|
+
new_execution = {}
|
37
|
+
job_execution_output.execution.attributes.each do |key, value|
|
38
|
+
# Remove _id from keys
|
39
|
+
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
new_execution[key] = value
|
42
|
+
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
# Append the new execution to the @response
|
45
|
+
@response[:executions].push(new_execution)
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
+
# Append the new job_execution_output to the @response
|
48
|
+
@response[:job_execution_outputs].push(new_job_execution_output)
|
49
|
+
end
|
50
|
+
end
|
47
51
|
end
|
48
52
|
end
|
@@ -1,68 +1,72 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Minicron
|
2
|
+
module Hub
|
3
|
+
class ScheduleSerializer
|
4
|
+
def initialize(schedules)
|
5
|
+
@schedules = schedules
|
6
|
+
end
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def serialize
|
9
|
+
@response = {
|
10
|
+
:schedules => [],
|
11
|
+
:jobs => []
|
12
|
+
}
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
if @schedules.respond_to? :each
|
15
|
+
@schedules.each do |schedule|
|
16
|
+
do_serialization(schedule)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
do_serialization(@schedules)
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
@response
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
+
def do_serialization(schedule)
|
26
|
+
new_schedule = {}
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
# Add all the normal attributes of the schedule
|
29
|
+
schedule.attributes.each do |key, value|
|
30
|
+
# Remove _id from keys
|
31
|
+
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
new_schedule[key] = value
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
# Add the formatted version of the schedule
|
37
|
+
new_schedule['formatted'] = schedule.formatted
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
# Add the schedule job to the sideloaded data
|
40
|
+
new_job = {
|
41
|
+
:schedules => [],
|
42
|
+
:executions => []
|
43
|
+
}
|
44
|
+
schedule.job.attributes.each do |key, value|
|
45
|
+
# To make our name method in the model work :/
|
46
|
+
value = schedule.job.name if key == 'name'
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
+
# Remove _id from keys
|
49
|
+
key = key[-3, 3] == '_id' ? key[0..-4] : key
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
+
new_job[key] = value
|
52
|
+
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
# Add the ids of each job schedule to the job
|
55
|
+
schedule.job.schedules.each do |s|
|
56
|
+
new_job[:schedules].push(s.id)
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
# Add the ids of each job execution to the job
|
60
|
+
schedule.job.executions.each do |execution|
|
61
|
+
new_job[:executions].push(execution.id)
|
62
|
+
end
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
+
# Append the new job to the @response
|
65
|
+
@response[:jobs].push(new_job)
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
# Append the new schedule to the @responseh
|
68
|
+
@response[:schedules].push(new_schedule)
|
69
|
+
end
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|
@@ -1,5 +1,11 @@
|
|
1
1
|
<script type="text/x-handlebars" id="executions/index">
|
2
|
-
|
2
|
+
<header>
|
3
|
+
<h2>Welcome to minicron!</h2>
|
4
|
+
</header>
|
5
|
+
<hr/>
|
6
|
+
|
7
|
+
To get started you need to {{#link-to 'hosts.new'}}set up a host{{/link-to}} and
|
8
|
+
then you can {{#link-to 'jobs.new'}}add your first job{{/link-to}}!
|
3
9
|
</script>
|
4
10
|
|
5
11
|
<script type="text/x-handlebars" id="execution/index">
|
@@ -150,7 +150,7 @@
|
|
150
150
|
<div class="form-group">
|
151
151
|
<label class="col-sm-2 control-label">Port</label>
|
152
152
|
<div class="col-sm-10">
|
153
|
-
{{input value=port type="text" class="form-control" placeholder="The port to connect on
|
153
|
+
{{input value=port type="text" class="form-control" placeholder="The port to connect on e.g 22"}}
|
154
154
|
</div>
|
155
155
|
</div>
|
156
156
|
<div class="form-group">
|
@@ -192,7 +192,7 @@
|
|
192
192
|
<div class="form-group">
|
193
193
|
<label class="col-sm-2 control-label">Port</label>
|
194
194
|
<div class="col-sm-10">
|
195
|
-
{{input value=port type="text" class="form-control" placeholder="The port to connect on
|
195
|
+
{{input value=port type="text" class="form-control" placeholder="The port to connect on e.g 22"}}
|
196
196
|
</div>
|
197
197
|
</div>
|
198
198
|
<div class="form-group">
|
@@ -313,7 +313,7 @@
|
|
313
313
|
|
314
314
|
<script type="text/x-handlebars" id="schedule/index">
|
315
315
|
<header class="clearfix">
|
316
|
-
<h2 class="pull-left">Schedule #{{id}}
|
316
|
+
<h2 class="pull-left">View Schedule #{{id}}</h2>
|
317
317
|
<a {{action 'delete' this}} class="pull-right btn btn-danger btn-sm">Delete</a>
|
318
318
|
{{#link-to 'schedule.edit' id class="pull-right btn btn-warning btn-sm"}}Edit{{/link-to}}
|
319
319
|
</header>
|
@@ -329,7 +329,7 @@
|
|
329
329
|
|
330
330
|
<script type="text/x-handlebars" id="schedules/new">
|
331
331
|
<header>
|
332
|
-
<h2>Add New Schedule
|
332
|
+
<h2>Add New Schedule</h2>
|
333
333
|
</header>
|
334
334
|
<hr/>
|
335
335
|
|
@@ -341,7 +341,7 @@
|
|
341
341
|
|
342
342
|
<script type="text/x-handlebars" id="schedule/edit">
|
343
343
|
<header class="clearfix">
|
344
|
-
<h2 class="pull-left">Edit Schedule #{{id}}
|
344
|
+
<h2 class="pull-left">Edit Schedule #{{id}}</h2>
|
345
345
|
<a {{action 'delete' this}} class="pull-right btn btn-danger btn-sm">Delete</a>
|
346
346
|
</header>
|
347
347
|
<hr/>
|