cpee 2.1.104 → 2.1.106

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f641a0e013ea34d5fcde9985698e424b88fc1083da2fa409a7ff49961e6ee7d
4
- data.tar.gz: 49b128e338257b1929c5bf7898479702542ee2612fc25aa447692480a1a72796
3
+ metadata.gz: 120f815f0f7416213d0187df51838246bfadbdbbc837e5d4d838bf906fc5fc6d
4
+ data.tar.gz: 675707c9d0963d88092549224c4701d11ca857921915c732267126595198062b
5
5
  SHA512:
6
- metadata.gz: 26e968160d080857bf4931dec48692c9dc049ee5c30eb72a9c555cc7eaae7cd9d72cb84a50284a75fcdb028dfe4b5634d1d7c5214a08d880b0ef31a47bf2a20a
7
- data.tar.gz: dc955cbfec7ac4d81a6528dd31c15eced6c07d34044551a8bcd3f0e8cce4e6289aaefd11928b7011e55789f06b9705aca8248f03c005179a0a43120c98805aa7
6
+ metadata.gz: 307601239e89aff52adbafbecd178ae742adf8b503e19f895b598152b28992b7300f3489afc87a2f91cc2f776320555759a761f3707ad125ae33091eb9dce1bc
7
+ data.tar.gz: 53659f21aa9416ad069b43efb1519b6b9cbcd6ee4da0305a53b282ce63e96e14b150bbad40f6b32d763d84c6665f41461c1d3bf8c34e643afaf558a54f564621
data/cpee.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee"
3
- s.version = "2.1.104"
3
+ s.version = "2.1.106"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "The cloud process execution engine (cpee.org). If you just need workflow execution, without a rest service exposing it, then use WEEL."
@@ -1,22 +1,18 @@
1
+ require 'cpee/constants'
1
2
  require 'yaml'
2
3
  opts = YAML::load_file(File.join(__dir__,'opts.yaml'))
3
4
  opts[:pidf] = __FILE__ + '.pid'
4
5
  opts[:pid] = Process.pid
5
6
 
6
- global_controller = File.join(opts[:global_executionhandlers],opts[:executionhandler],'controller.rb')
7
- controller = File.join(opts[:executionhandlers], opts[:executionhandler],'controller.rb')
8
- if File.exist? global_controller
9
- require global_controller
10
- elsif File.exist? controller
11
- require controller
12
- end
13
-
14
- global_connectionhandler = File.join(opts[:global_executionhandlers],opts[:executionhandler],'connection.rb')
15
- connectionhandler = File.join(opts[:executionhandlers], opts[:executionhandler],'connection.rb')
16
- if File.exist? global_connectionhandler
17
- require global_connectionhandler
18
- elsif File.exist? connectionhandler
19
- require connectionhandler
7
+ opts[:global_executionhandlers] = CPEE::GLOBAL_EXECUTIONHANDLERS unless opts[:global_executionhandlers]
8
+ ['controller.rb','connection.rb'].each do |f|
9
+ global_thing = File.join(opts[:global_executionhandlers],opts[:executionhandler],f)
10
+ thing = File.join(opts[:executionhandlers], opts[:executionhandler],f)
11
+ if File.exist? global_thing
12
+ require global_thing
13
+ elsif File.exist? thing
14
+ require thing
15
+ end
20
16
  end
21
17
 
22
18
  require_relative 'instance'
@@ -35,7 +35,7 @@ module CPEE
35
35
  hw = CPEE::Persistence::extract_item(id,opts,'executionhandler')
36
36
  endpoints = CPEE::Persistence::extract_list(id,opts,'endpoints')
37
37
  dataelements = CPEE::Persistence::extract_list(id,opts,'dataelements')
38
- attributes = CPEE::Persistence::extract_list(id,opts,'attributes')
38
+ attributes = CPEE::Persistence::extract_list(id,opts,'attributes').to_h
39
39
  positions = CPEE::Persistence::extract_set(id,opts,'positions')
40
40
  positions.map! do |k, v|
41
41
  [ k, v, CPEE::Persistence::extract_item(id,opts,File.join('positions',k,'@passthrough')) ]
@@ -46,9 +46,14 @@ module CPEE
46
46
  iopts[:redis_url] = opts[:redis_url]
47
47
  iopts[:redis_db] = opts[:redis_db]
48
48
  iopts[:workers] = opts[:workers]
49
- iopts[:global_executionhandlers] = opts[:global_executionhandlers]
50
- iopts[:executionhandlers] = opts[:executionhandlers]
51
49
  iopts[:executionhandler] = hw
50
+ if attributes.has_key?('remote')
51
+ uri = URI::parse(attributes['remote'])
52
+ iopts[:executionhandlers] = File.join(uri.path,File.basename(opts[:executionhandlers]))
53
+ else
54
+ iopts[:executionhandlers] = opts[:executionhandlers]
55
+ iopts[:global_executionhandlers] = opts[:global_executionhandlers]
56
+ end
52
57
 
53
58
  File.open(File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Eval::BACKEND_OPTS)),'w') do |f|
54
59
  YAML::dump(iopts,f)
@@ -56,24 +61,55 @@ module CPEE
56
61
  template = ERB.new(File.read(ExecutionHandler::Eval::BACKEND_TEMPLATE), trim_mode: '-')
57
62
  res = template.result_with_hash(dsl: dsl, dataelements: dataelements, endpoints: endpoints, positions: positions)
58
63
  File.write(File.join(opts[:instances],id.to_s,ExecutionHandler::Eval::BACKEND_INSTANCE),res)
64
+ if attributes.has_key?('remote')
65
+ uri = URI::parse(attributes['remote'])
66
+ Net::SSH.start(uri.host,uri.user,:keys => [ opts[:ssh_key] ] ) do |ssh|
67
+ ssh.exec!("rm -rf #{File.join(uri.path,id.to_s,'*')}")
68
+ ssh.scp.upload!(File.join(opts[:instances],id.to_s),uri.path,:recursive=>true)
69
+ end
70
+ File.write(File.join(opts[:instances],id.to_s,'.remote'),attributes['remote'])
71
+ end
59
72
  end
60
73
 
61
74
  def self::run(id,opts)
62
- exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Eval::BACKEND_RUN))
63
- pid = Kernel.spawn(opts[:libs_preloaderrun] + ' ' + exe , :pgroup => true, :in => '/dev/null', :out => exe + '.out', :err => exe + '.err')
64
- Process.detach pid
65
- File.write(exe + '.pid',pid)
75
+ if File.exist? File.join(opts[:instances],id.to_s,'.remote')
76
+ uri = URI::parse(File.read(File.join(opts[:instances],id.to_s,'.remote')))
77
+ exe = File.join(uri.path,id.to_s,File.basename(BACKEND_RUN))
78
+ Net::SSH.start(uri.host,uri.user,:keys => [ opts[:ssh_key] ] ) do |ssh|
79
+ ssh.exec!("ruby #{exe} >#{exe}.out 2>#{exe}.err &")
80
+ end
81
+ else
82
+ exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Eval::BACKEND_RUN))
83
+ pid = Kernel.spawn(opts[:libs_preloaderrun] + ' ' + exe , :pgroup => true, :in => '/dev/null', :out => exe + '.out', :err => exe + '.err')
84
+ Process.detach pid
85
+ File.write(exe + '.pid',pid)
86
+ end
66
87
  end
67
88
 
68
89
  def self::stop(id,opts) ### return: bool to tell if manually changing redis is necessary
69
- exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Eval::BACKEND_RUN))
70
- pid = File.read(exe + '.pid') rescue nil
71
- if pid && (Process.kill(0, pid.to_i) rescue false)
72
- Process.kill('HUP', pid.to_i) rescue nil
73
- false
74
- else # its not running, so clean up
75
- File.unlink(exe + '.pid') rescue nil
76
- true
90
+ if File.exist? File.join(opts[:instances],id.to_s,'.remote')
91
+ uri = URI::parse(File.read(File.join(opts[:instances],id.to_s,'.remote')))
92
+ exe = File.join(uri.path,id.to_s,File.basename(BACKEND_RUN))
93
+ Net::SSH.start(uri.host,uri.user,:keys => [ opts[:ssh_key] ] ) do |ssh|
94
+ pid = ssh.exec!("cat #{exe}.pid 2>/dev/null")
95
+ if pid != '' && ssh.exec!("kill -0 #{pid} >/dev/null 2>&1; echo $?").strip == '0'
96
+ ssh.exec!("kill -SIGHUP #{pid}")
97
+ false
98
+ else
99
+ ssh.exec!("rm #{exe}.pid")
100
+ true
101
+ end
102
+ end
103
+ else
104
+ exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Eval::BACKEND_RUN))
105
+ pid = File.read(exe + '.pid') rescue nil
106
+ if pid && (Process.kill(0, pid.to_i) rescue false)
107
+ Process.kill('HUP', pid.to_i) rescue nil
108
+ false
109
+ else # its not running, so clean up
110
+ File.unlink(exe + '.pid') rescue nil
111
+ true
112
+ end
77
113
  end
78
114
  end
79
115
  end
@@ -76,27 +76,44 @@ module CPEE
76
76
  end
77
77
 
78
78
  def self::run(id,opts)
79
- ### if File file .remote
80
- ### connect to remote
81
- ### run same as below
82
- ### else
83
- ### Determine whether we run locally or remote
79
+ if File.exist? File.join(opts[:instances],id.to_s,'.remote')
80
+ uri = URI::parse(File.read(File.join(opts[:instances],id.to_s,'.remote')))
81
+ exe = File.join(uri.path,id.to_s,File.basename(BACKEND_RUN))
82
+ Net::SSH.start(uri.host,uri.user,:keys => [ opts[:ssh_key] ] ) do |ssh|
83
+ ssh.exec!("ruby #{exe} >#{exe}.out 2>#{exe}.err &")
84
+ end
85
+ else
84
86
  exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Ruby::BACKEND_RUN))
85
87
  pid = Kernel.spawn(opts[:libs_preloaderrun] + ' ' + exe , :pgroup => true, :in => '/dev/null', :out => exe + '.out', :err => exe + '.err')
86
88
  Process.detach pid
87
89
  File.write(exe + '.pid',pid)
88
- ### end
90
+ end
89
91
  end
90
92
 
91
93
  def self::stop(id,opts) ### return: bool to tell if manually changing redis is necessary
92
- exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Ruby::BACKEND_RUN))
93
- pid = File.read(exe + '.pid') rescue nil
94
- if pid && (Process.kill(0, pid.to_i) rescue false)
95
- Process.kill('HUP', pid.to_i) rescue nil
96
- false
97
- else # its not running, so clean up
98
- File.unlink(exe + '.pid') rescue nil
99
- true
94
+ if File.exist? File.join(opts[:instances],id.to_s,'.remote')
95
+ uri = URI::parse(File.read(File.join(opts[:instances],id.to_s,'.remote')))
96
+ exe = File.join(uri.path,id.to_s,File.basename(BACKEND_RUN))
97
+ Net::SSH.start(uri.host,uri.user,:keys => [ opts[:ssh_key] ] ) do |ssh|
98
+ pid = ssh.exec!("cat #{exe}.pid 2>/dev/null")
99
+ if pid != '' && ssh.exec!("kill -0 #{pid} >/dev/null 2>&1; echo $?").strip == '0'
100
+ ssh.exec!("kill -SIGHUP #{pid}")
101
+ false
102
+ else
103
+ ssh.exec!("rm #{exe}.pid")
104
+ true
105
+ end
106
+ end
107
+ else
108
+ exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Ruby::BACKEND_RUN))
109
+ pid = File.read(exe + '.pid') rescue nil
110
+ if pid && (Process.kill(0, pid.to_i) rescue false)
111
+ Process.kill('HUP', pid.to_i) rescue nil
112
+ false
113
+ else # its not running, so clean up
114
+ File.unlink(exe + '.pid') rescue nil
115
+ true
116
+ end
100
117
  end
101
118
  end
102
119
  end
@@ -1 +1 @@
1
- 577032
1
+ 601746
@@ -1 +1 @@
1
- 577074
1
+ 601788
@@ -1 +1 @@
1
- 577060
1
+ 601774
@@ -1 +1 @@
1
- 577046
1
+ 601760
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.104
4
+ version: 2.1.106
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler