omf_rc_shm 0.1.19 → 0.1.20
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 +21 -1
- data/config/config.yml +0 -8
- data/config/scheduled_app.rb +4 -0
- data/lib/omf_rc/resource_proxy/scheduled_application.rb +3 -1
- data/lib/omf_rc/resource_proxy/shm_node.rb +3 -35
- data/lib/omf_rc_shm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjNiMWFjMTE5MTU1OTFhZjMwM2FjMThiNDM5NzJmNGY3YWRhMWM1Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTlkYWE4ZmRkMmRkZjgyOTcyZjFlZmRhMTJiNzRiYWM2ZmMyZjk3MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjJiMGRiYzA5YTE4NjljMTk2NTU1YTJjNzdlZGIxMDU3OGE1ZGFlYjdkY2Qx
|
10
|
+
MDcwMTc5ZjdiYTNmYzdmMzM5Mjg5ODY3ZGY1MmU2MGM3YmQ1ZGVmOTAyYjE0
|
11
|
+
MDY4Nzk5NTViNTZmZDcyNjQ0ZmMwMmIyNjJiOWNjODI2YTdlYmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTI1OGUwMTNhNWUwMjBlYmM1ODIyN2E1M2U5OWJkMDI5NWUyYzZmM2FlZWRm
|
14
|
+
MzJkYTUwMTlmMDllZmExNGQ3ZDg4ZjM4YzMyMzUzMTFhM2FhOTZjZjcwNDNk
|
15
|
+
NGM3YzRiOGFlYWM2M2E5MjNkZjRmNjJkNTlhMmI4MGQ0NTQyMjM=
|
data/bin/cronjob_app_wrapper
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
require 'oml4r'
|
4
|
+
|
5
|
+
# Get the Mac address and node ID
|
6
|
+
ifconfig = '/sbin/ifconfig br0'
|
7
|
+
mac_address = `#{ifconfig}`.match(/HWaddr (\h*\:\h*\:\h*\:\h*:\h*:\h*)/)[1]
|
8
|
+
node_id = (mac_address.split(':')[4]+mac_address.split(':')[5]).hex.to_s.rjust(5,'0')
|
9
|
+
|
10
|
+
odomain, ocollect, stdout_f, stderr_f, pid_f, timeout, kill_sig, *cmd = *ARGV
|
11
|
+
|
12
|
+
# Record into OML
|
13
|
+
class InfoMP < OML4R::MPBase
|
14
|
+
name :app_info
|
15
|
+
param :app_path
|
16
|
+
param :app_start, :type => :double
|
17
|
+
param :app_duration, :type => :double
|
18
|
+
param :app_param
|
19
|
+
end
|
20
|
+
opts = {:domain => odomain, :collect => ocollect, :appName => 'cronwrap', :nodeID => node_id}
|
21
|
+
OML4R::init(nil, opts)
|
22
|
+
InfoMP.inject(cmd[0], Time.now.to_i, timeout.to_i, cmd.drop(1).join(' '))
|
23
|
+
OML4R::close()
|
4
24
|
|
5
25
|
pid = Process.spawn(cmd.join(" "), out: [stdout_f, "a"], err: [stderr_f, "a"])
|
6
26
|
|
data/config/config.yml
CHANGED
@@ -23,14 +23,6 @@
|
|
23
23
|
# The top-up value in second for the watchdog timer (must be lower than timeout value)
|
24
24
|
# Comment that line to disable the watchdog timer
|
25
25
|
:watchdog_timer: 15
|
26
|
-
# Ensure local time is synced with NTP time before doing anything else.
|
27
|
-
# Local time is considered synced if it is within 'time_sync_maxdrift' second drift of NTP time.
|
28
|
-
# It will try 'time_sync_tries' times to do time sync using the command 'time_sync_cmd'.
|
29
|
-
# Each failed sync attempt will trigger a random sleep up to 'time_sync_interval' second before the next attempt.
|
30
|
-
:time_sync_tries: 20
|
31
|
-
:time_sync_maxdrift: 600
|
32
|
-
:time_sync_interval: 20
|
33
|
-
:time_sync_cmd: "/usr/bin/ntpdate -b -t 10 -u au.pool.ntp.org"
|
34
26
|
|
35
27
|
:add_default_factories: false # Not loading default type factories
|
36
28
|
|
data/config/scheduled_app.rb
CHANGED
@@ -106,6 +106,7 @@ module OmfRc::ResourceProxy::ScheduledApplication
|
|
106
106
|
property :app_log_dir, :default => '/tmp/omf_scheduled_app'
|
107
107
|
property :ruby_path
|
108
108
|
property :parent_id
|
109
|
+
property :instrument_launch, :default => Hashie::Mash.new(domain: 'null', url: 'file:/dev/null')
|
109
110
|
|
110
111
|
# @!macro group_hook
|
111
112
|
#
|
@@ -335,7 +336,8 @@ module OmfRc::ResourceProxy::ScheduledApplication
|
|
335
336
|
|
336
337
|
app_wrapper_path = File.expand_path("#{File.dirname(__FILE__)}/../../../bin/cronjob_app_wrapper")
|
337
338
|
|
338
|
-
cmd = "#{app_wrapper_path} #{
|
339
|
+
cmd = "#{app_wrapper_path} #{res.property.instrument_launch.domain} #{res.property.instrument_launch.url}"
|
340
|
+
cmd = "#{cmd} #{stdout_file} #{stderr_file} #{pid_file} #{res.property.timeout} #{res.property.timeout_kill_signal} #{res.build_command_line}"
|
339
341
|
cmd = "#{res.property.ruby_path} #{cmd}" if res.property.ruby_path
|
340
342
|
|
341
343
|
info "Adding cron job for '#{res.property.app_id}' with schedule '#{cron_schedule}' and command '#{cmd}'"
|
@@ -7,10 +7,6 @@ module OmfRc::ResourceProxy::ShmNode
|
|
7
7
|
property :oml_uri
|
8
8
|
property :ruby_path
|
9
9
|
property :watchdog_timer, :default => nil
|
10
|
-
property :time_sync_tries, :default => nil
|
11
|
-
property :time_sync_maxdrift, :default => 600
|
12
|
-
property :time_sync_interval, :default => 20
|
13
|
-
property :time_sync_cmd, :default => "/usr/bin/ntpdate -b -t 10 -u au.pool.ntp.org"
|
14
10
|
|
15
11
|
request :cron_jobs do |node|
|
16
12
|
node.children.find_all { |v| v.type =~ /scheduled_application/ }.map do |v|
|
@@ -19,35 +15,7 @@ module OmfRc::ResourceProxy::ShmNode
|
|
19
15
|
end
|
20
16
|
|
21
17
|
hook :after_initial_configured do |node|
|
22
|
-
# 1)
|
23
|
-
unless node.property.time_sync_tries.nil?
|
24
|
-
require 'net/ntp'
|
25
|
-
info "Option 'time_sync_tries' is set. Continue only if local time is accurate, will try to sync #{node.property.time_sync_tries} times with random wait of up to #{node.property.time_sync_interval}s."
|
26
|
-
dt = node.property.time_sync_maxdrift.to_i + 1
|
27
|
-
lt = rt = t = 0
|
28
|
-
while dt >node.property.time_sync_maxdrift.to_i do
|
29
|
-
t = t+1
|
30
|
-
begin
|
31
|
-
lt = Time.now ; rt = Net::NTP.get.time ; dt = (lt-rt).abs
|
32
|
-
if dt > node.property.time_sync_maxdrift.to_i
|
33
|
-
info "Time sync try #{t} - Local: #{lt.to_i} - NTP: #{rt.to_i} - Diff: #{dt} - (sync: #{node.property.time_sync_cmd.to_s})"
|
34
|
-
res = `#{node.property.time_sync_cmd.to_s}`
|
35
|
-
sleep(rand(node.property.time_sync_interval.to_i))
|
36
|
-
else
|
37
|
-
break
|
38
|
-
end
|
39
|
-
rescue Exception => e
|
40
|
-
info "Time sync try #{t} - Cannot contact NTP server (#{e})"
|
41
|
-
sleep(rand(node.property.time_sync_interval.to_i))
|
42
|
-
end
|
43
|
-
if t > node.property.time_sync_tries.to_i
|
44
|
-
info "Time sync FAILED! EXITING NOW!"
|
45
|
-
exit
|
46
|
-
end
|
47
|
-
end
|
48
|
-
info "Time sync OK - Local: #{lt.to_i} - NTP: #{rt.to_i} - Diff: #{dt}"
|
49
|
-
end
|
50
|
-
# 2) if present, load and set default app schedule
|
18
|
+
# 1) if present, load and set default app schedule
|
51
19
|
unless node.request_app_definition_file.nil?
|
52
20
|
OmfRcShm.app.load_definition(node.request_app_definition_file)
|
53
21
|
info "Loaded scheduled app definition from '#{node.request_app_definition_file}'"
|
@@ -60,7 +28,7 @@ module OmfRc::ResourceProxy::ShmNode
|
|
60
28
|
OmfCommon.el.after(5) { s_app.configure_state(:scheduled) }
|
61
29
|
end
|
62
30
|
end
|
63
|
-
#
|
31
|
+
# 2) if required, start the watchdog timer and periodically top it
|
64
32
|
unless node.property.watchdog_timer.nil?
|
65
33
|
info "Watchdog Timer started with interval: #{node.property.watchdog_timer}"
|
66
34
|
OmfRcShm.app.watchdog = File.open('/dev/watchdog', 'w')
|
@@ -69,7 +37,7 @@ module OmfRc::ResourceProxy::ShmNode
|
|
69
37
|
OmfRcShm.app.watchdog.flush
|
70
38
|
end
|
71
39
|
end
|
72
|
-
#
|
40
|
+
# 3) Finally display our SHM Node ID:
|
73
41
|
info "SHM Node ID: #{node.uid}"
|
74
42
|
end
|
75
43
|
|
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.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NICTA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|