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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWI4OGY2NmNkZDk0ZjFkYzA5NTUyNzA4MzZkYWFmMzUxNjMzMjc0NA==
4
+ MWI0MmIwNjMzMWJjMDA3OGJmMWQ1MTZlYWZkZmRkYTcxNjEzNjk3MQ==
5
5
  data.tar.gz: !binary |-
6
- M2ZjMGIzNzQ4OWEyY2Y1NTlkNGRkNTY5NjJjYjAxMTI3NDA2MjFkZQ==
6
+ MWJlYjQ3MzFhMWE5ZWIyNGJhMWQzZDAwNzQ3YmNiMDJjMTBhZDkxMg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTlmZGQ3YWVkZmVkZmExODc2YzI2NzI2ODYwM2ZmZjZkOWQwMjdhZjNhNzEy
10
- OWNhY2E4NDM3ZTNiZjIxNDVjOTdjYTMyMGFkNTUxMjNiOTM3ZGRiMWMzZGVi
11
- MjQ1YTgxYjhjYTYxMWY5NzkxYTAwYmE5N2YyODk0YWNiZTI3OTA=
9
+ MjEyMzM2NDllODM3ZWE3NzZjMjAxYTZkOWM2YWQ2NzY1ZDM0NGY2N2M3MDI4
10
+ NWY2NmE1NGM1YzcxYmMyMGI1NTk5Y2QwNDhhZWU2ZWQ0ZTQzOGQ5Y2ZkMmFj
11
+ ZmVlYTMzYTI1OWM3MGRlYWQwMDNjNDQxODFjYmI2Mjc2MjEwODg=
12
12
  data.tar.gz: !binary |-
13
- Y2Y5M2U2ZGNiOWIwZjUzNTRjNjJjZTMwZjhhNmQ2NDgxZGZlNzkyNWQzZWE1
14
- Zjk3MGEzYmYyNDljN2MzYTNlNzg4NGMwODNiNjgxNDczZDhlNDRiYjYxMjAz
15
- ZDlhY2IyM2I0ZWE4ODhlMDljNDlmMDZhNTgzNDQ5MGM0MDA0MTM=
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
- App.define(
2
- "otr2", {
3
- schedule: "* * * * *",
4
- timeout: 20,
5
- binary_path: "/usr/bin/otr2",
6
- use_oml: true,
7
- parameters: {
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
- cmd = "ruby -e 'extend Process
328
- pid = spawn(\"#{res.build_command_line}\", :out=>[\"#{stdout_file}\", \"a\"], :err=>[\"#{stderr_file}\", \"a\"])
329
- `echo \#{pid} >> #{pid_file}`
330
- fork {
331
- sleep #{res.property.timeout}
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
- cmd_line = "env -i " # Start with a 'clean' environment
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[:hrn] = name
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
@@ -17,9 +17,5 @@ module OmfRcShm
17
17
  def load_definition(file_path)
18
18
  eval(File.read(file_path))
19
19
  end
20
-
21
- def self.define(app_name, app_opts)
22
- self.instance.definitions[app_name] = app_opts
23
- end
24
20
  end
25
21
  end
@@ -1,3 +1,3 @@
1
1
  module OmfRcShm
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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-09 00:00:00.000000000 Z
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