omf_rc_shm 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 +8 -8
- data/bin/cronjob_app_wrapper +19 -0
- data/config/test.rb +23 -37
- data/lib/omf_rc/resource_proxy/scheduled_application.rb +9 -11
- data/lib/omf_rc/resource_proxy/shm_node.rb +2 -3
- data/lib/omf_rc_shm/app.rb +0 -4
- data/lib/omf_rc_shm/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWI0MmIwNjMzMWJjMDA3OGJmMWQ1MTZlYWZkZmRkYTcxNjEzNjk3MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWJlYjQ3MzFhMWE5ZWIyNGJhMWQzZDAwNzQ3YmNiMDJjMTBhZDkxMg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjEyMzM2NDllODM3ZWE3NzZjMjAxYTZkOWM2YWQ2NzY1ZDM0NGY2N2M3MDI4
|
10
|
+
NWY2NmE1NGM1YzcxYmMyMGI1NTk5Y2QwNDhhZWU2ZWQ0ZTQzOGQ5Y2ZkMmFj
|
11
|
+
ZmVlYTMzYTI1OWM3MGRlYWQwMDNjNDQxODFjYmI2Mjc2MjEwODg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTdhZWNmY2JjZmE3ZjRkMjA2MzI4YTYyNzk3NzhmYTIzYzdiNWI3YzM2MWY1
|
14
|
+
NzEyYmUwNTA4Njk0ZjQ4MTgxYTc1MDY0ODJlNTcyZTQ1Mzc1ODY3NmMzODI0
|
15
|
+
NmNjYTY5YTg1MGNiNzBlNTllZDI2NDc3MmU0NTRhYzljNWI1MTg=
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
cmd, stdout_f, stderr_f, pid_f, timeout, kill_sig = *ARGV
|
4
|
+
|
5
|
+
pid = Process.spawn(cmd, out: [stdout_f, "a"], err: [stderr_f, "a"])
|
6
|
+
|
7
|
+
`echo #{pid} >> #{pid_f}`
|
8
|
+
|
9
|
+
if timeout && timeout.to_i > 0
|
10
|
+
fork do
|
11
|
+
sleep timeout.to_i
|
12
|
+
Process.kill(kill_sig, pid)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Process.waitpid(pid)
|
17
|
+
|
18
|
+
`echo Process #{pid} exited with code: #{$?.exitstatus} >> #{stderr_f}`
|
19
|
+
|
data/config/test.rb
CHANGED
@@ -1,39 +1,25 @@
|
|
1
|
-
|
2
|
-
"
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
udp_local_host: { cmd: "--udp:local_host", value: "0.0.0.0" }
|
9
|
-
},
|
10
|
-
oml: {
|
11
|
-
experiment: "otr2_#{Time.now.to_i}",
|
12
|
-
id: "otr2",
|
13
|
-
available_mps: [
|
14
|
-
{
|
15
|
-
mp: "udp_in",
|
16
|
-
fields: [
|
17
|
-
{ field: "flow_id", type: :long },
|
18
|
-
{ field: "seq_no", type: :long },
|
19
|
-
{ field: "pkt_length", type: :long },
|
20
|
-
{ field: "dst_host", type: :string },
|
21
|
-
{ field: "dst_port", type: :long }
|
22
|
-
]
|
23
|
-
}
|
24
|
-
],
|
25
|
-
collection: [
|
26
|
-
{
|
27
|
-
url: "tcp:0.0.0.0:3003",
|
28
|
-
streams: [
|
29
|
-
{
|
30
|
-
mp: "udp_in",
|
31
|
-
interval: 3
|
32
|
-
}
|
33
|
-
]
|
34
|
-
}
|
35
|
-
]
|
36
|
-
}
|
1
|
+
defApplication("otr2") do |a|
|
2
|
+
a.schedule = "* * * * *"
|
3
|
+
a.timeout = 20
|
4
|
+
a.binary_path = "/usr/bin/otr2"
|
5
|
+
a.use_oml = true
|
6
|
+
a.parameters = {
|
7
|
+
udp_local_host: { cmd: "--udp:local_host", value: "0.0.0.0" }
|
37
8
|
}
|
38
|
-
|
9
|
+
a.oml = {
|
10
|
+
experiment: "otr2_#{Time.now.to_i}",
|
11
|
+
id: "otr2",
|
12
|
+
collection: [
|
13
|
+
{
|
14
|
+
url: "tcp:0.0.0.0:3003",
|
15
|
+
streams: [
|
16
|
+
{
|
17
|
+
mp: "udp_in",
|
18
|
+
interval: 3
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}
|
22
|
+
]
|
23
|
+
}
|
24
|
+
end
|
39
25
|
|
@@ -324,17 +324,13 @@ module OmfRc::ResourceProxy::ScheduledApplication
|
|
324
324
|
File.delete(stderr_file) if File.exist?(stderr_file)
|
325
325
|
File.delete(stdout_file) if File.exist?(stdout_file)
|
326
326
|
File.delete(pid_file) if File.exist?(pid_file)
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
kill(\"#{res.property.timeout_kill_signal}\", pid)
|
333
|
-
} if #{res.property.timeout} > 0
|
334
|
-
waitpid(pid)
|
335
|
-
`echo Process \#{pid} exited with code: \#{$?.exitstatus} >> #{stderr_file}`'"
|
336
|
-
cmd.gsub!(/[\n]+/, ";") # make it a one-liner
|
327
|
+
|
328
|
+
app_wrapper_path = File.expand_path("#{File.dirname(__FILE__)}/../../../bin/cronjob_app_wrapper")
|
329
|
+
|
330
|
+
cmd = "#{app_wrapper_path} #{res.build_command_line} #{stdout_file} #{stderr_file} #{pid_file} #{res.property.timeout} #{res.property.timeout_kill_signal}"
|
331
|
+
|
337
332
|
info "Adding cron job for '#{res.property.app_id}' with schedule '#{res.property.schedule}' and command '#{cmd}'"
|
333
|
+
|
338
334
|
CronEdit::Crontab.Add res.property.app_id, "#{res.property.schedule} #{cmd}"
|
339
335
|
res.property.file_change_callback = Proc.new do |modified, added, removed|
|
340
336
|
removed.each do |file|
|
@@ -431,7 +427,9 @@ waitpid(pid)
|
|
431
427
|
# @return [String] the full command line
|
432
428
|
# @!macro work
|
433
429
|
work('build_command_line') do |res|
|
434
|
-
|
430
|
+
# TODO is this necessary?
|
431
|
+
#cmd_line = "env -i " # Start with a 'clean' environment
|
432
|
+
cmd_line = ""
|
435
433
|
res.property.environments.each do |e,v|
|
436
434
|
val = v.kind_of?(String) ? "'#{v}'" : v
|
437
435
|
cmd_line += "#{e.to_s.upcase}=#{val} "
|
@@ -17,9 +17,8 @@ module OmfRc::ResourceProxy::ShmNode
|
|
17
17
|
|
18
18
|
OmfRcShm.app.definitions.each do |name, app_opts|
|
19
19
|
info "Got definition #{app_opts.inspect}, now schedule them..."
|
20
|
-
app_opts
|
21
|
-
|
22
|
-
s_app = OmfRc::ResourceFactory.create(:scheduled_application, app_opts)
|
20
|
+
opts = app_opts.properties.merge(hrn: name)
|
21
|
+
s_app = OmfRc::ResourceFactory.create(:scheduled_application, opts)
|
23
22
|
OmfCommon.el.after(5) do
|
24
23
|
s_app.configure_state(:scheduled)
|
25
24
|
end
|
data/lib/omf_rc_shm/app.rb
CHANGED
data/lib/omf_rc_shm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_rc_shm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NICTA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,7 +97,8 @@ dependencies:
|
|
97
97
|
description:
|
98
98
|
email:
|
99
99
|
- omf-user@lists.nicta.com.au
|
100
|
-
executables:
|
100
|
+
executables:
|
101
|
+
- cronjob_app_wrapper
|
101
102
|
extensions: []
|
102
103
|
extra_rdoc_files: []
|
103
104
|
files:
|
@@ -106,6 +107,7 @@ files:
|
|
106
107
|
- LICENSE.txt
|
107
108
|
- README.md
|
108
109
|
- Rakefile
|
110
|
+
- bin/cronjob_app_wrapper
|
109
111
|
- config/rc.yml.sample
|
110
112
|
- config/test.rb
|
111
113
|
- lib/omf_rc/resource_proxy/scheduled_application.rb
|