cpee 2.1.103 → 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: 89afb8a2610ae012039da0f247086f5512de982659d2b1c71321add823a28235
4
- data.tar.gz: deb4fb653b1ca9323d017c2777d5206765d5334b318383331388e1eee54f6bd0
3
+ metadata.gz: 120f815f0f7416213d0187df51838246bfadbdbbc837e5d4d838bf906fc5fc6d
4
+ data.tar.gz: 675707c9d0963d88092549224c4701d11ca857921915c732267126595198062b
5
5
  SHA512:
6
- metadata.gz: fe1c1382d75a729659f646dae9c0de4a2a8296578f16e64d964ee0813a33cefb8964e823a306138a4f4473b70f0f81043c28a036f18d6dc2fdc21a7089591975
7
- data.tar.gz: 7b9cb494d6b622fa1d4f3e56c2aba7190803188a83bfb75468d292d05055d449deb6de0ea8e2906a036d9f8eb50a8276966df6004e338da1510e2d8884b2e4be
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.103"
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."
@@ -0,0 +1,18 @@
1
+ # This file is part of CPEE.
2
+ #
3
+ # CPEE is free software: you can redistribute it and/or modify it under the terms
4
+ # of the GNU General Public License as published by the Free Software Foundation,
5
+ # either version 3 of the License, or (at your option) any later version.
6
+ #
7
+ # CPEE is distributed in the hope that it will be useful, but WITHOUT ANY
8
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
9
+ # PARTICULAR PURPOSE. See the GNU General Public License for more details.
10
+ #
11
+ # You should have received a copy of the GNU General Public License along with
12
+ # CPEE (file COPYING in the main directory). If not, see
13
+ # <http://www.gnu.org/licenses/>.
14
+
15
+ module CPEE
16
+ LIBPATH = __dir__
17
+ GLOBAL_EXECUTIONHANDLERS = File.expand_path(File.join(__dir__,'..','..','server','executionhandlers'))
18
+ end
@@ -24,6 +24,7 @@ require_relative 'statemachine'
24
24
  require_relative 'implementation_properties'
25
25
  require_relative 'implementation_notifications'
26
26
  require_relative 'implementation_callbacks'
27
+ require_relative 'constants'
27
28
 
28
29
  module CPEE
29
30
 
@@ -94,6 +95,9 @@ module CPEE
94
95
  opts[:libs_preloader] ||= '~/bin/by-server'
95
96
  opts[:libs_preloaderrun] ||= '~/bin/by'
96
97
 
98
+ ### for remote deployment (attribute remote)
99
+ opts[:ssh_key] ||= '~/.ssh/dist.key'
100
+
97
101
  CPEE::redis_connect opts, 'Server Main'
98
102
 
99
103
  ### start by server
@@ -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
@@ -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'
@@ -12,6 +12,9 @@
12
12
  # CPEE (file COPYING in the main directory). If not, see
13
13
  # <http://www.gnu.org/licenses/>.
14
14
 
15
+ require 'net/ssh'
16
+ require 'net/scp'
17
+
15
18
  module CPEE
16
19
 
17
20
  module ExecutionHandler
@@ -29,13 +32,14 @@ module CPEE
29
32
  end
30
33
 
31
34
  def self::prepare(id,opts) # write result to disk
35
+ FileUtils.rm_rf(Dir.glob(File.join(opts[:instances],id.to_s,'*')) + Dir.glob(File.join(opts[:instances],id.to_s,'.remote')))
32
36
  Dir.mkdir(File.join(opts[:instances],id.to_s)) rescue nil
33
37
  FileUtils.copy(ExecutionHandler::Ruby::BACKEND_RUN,File.join(opts[:instances],id.to_s))
34
38
  dsl = CPEE::Persistence::extract_item(id,opts,'dsl')
35
39
  hw = CPEE::Persistence::extract_item(id,opts,'executionhandler')
36
40
  endpoints = CPEE::Persistence::extract_list(id,opts,'endpoints')
37
41
  dataelements = CPEE::Persistence::extract_list(id,opts,'dataelements')
38
- attributes = CPEE::Persistence::extract_list(id,opts,'attributes')
42
+ attributes = CPEE::Persistence::extract_list(id,opts,'attributes').to_h
39
43
  positions = CPEE::Persistence::extract_set(id,opts,'positions')
40
44
  positions.map! do |k, v|
41
45
  [ k, v, CPEE::Persistence::extract_item(id,opts,File.join('positions',k,'@passthrough')) ]
@@ -46,9 +50,14 @@ module CPEE
46
50
  iopts[:redis_url] = opts[:redis_url]
47
51
  iopts[:redis_db] = opts[:redis_db]
48
52
  iopts[:workers] = opts[:workers]
49
- iopts[:global_executionhandlers] = opts[:global_executionhandlers]
50
- iopts[:executionhandlers] = opts[:executionhandlers]
51
53
  iopts[:executionhandler] = hw
54
+ if attributes.has_key?('remote')
55
+ uri = URI::parse(attributes['remote'])
56
+ iopts[:executionhandlers] = File.join(uri.path,File.basename(opts[:executionhandlers]))
57
+ else
58
+ iopts[:executionhandlers] = opts[:executionhandlers]
59
+ iopts[:global_executionhandlers] = opts[:global_executionhandlers]
60
+ end
52
61
 
53
62
  File.open(File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Ruby::BACKEND_OPTS)),'w') do |f|
54
63
  YAML::dump(iopts,f)
@@ -56,34 +65,55 @@ module CPEE
56
65
  template = ERB.new(File.read(ExecutionHandler::Ruby::BACKEND_TEMPLATE), trim_mode: '-')
57
66
  res = template.result_with_hash(dsl: dsl, dataelements: dataelements, endpoints: endpoints, positions: positions)
58
67
  File.write(File.join(opts[:instances],id.to_s,ExecutionHandler::Ruby::BACKEND_INSTANCE),res)
59
- # if attributes['remote']
60
- # ### scp instance files to the remote server under run (under instance id)
61
- # ### touch local .remote with connection details
62
- # end
68
+ if attributes.has_key?('remote')
69
+ uri = URI::parse(attributes['remote'])
70
+ Net::SSH.start(uri.host,uri.user,:keys => [ opts[:ssh_key] ] ) do |ssh|
71
+ ssh.exec!("rm -rf #{File.join(uri.path,id.to_s,'*')}")
72
+ ssh.scp.upload!(File.join(opts[:instances],id.to_s),uri.path,:recursive=>true)
73
+ end
74
+ File.write(File.join(opts[:instances],id.to_s,'.remote'),attributes['remote'])
75
+ end
63
76
  end
64
77
 
65
78
  def self::run(id,opts)
66
- ### if File file .remote
67
- ### connect to remote
68
- ### run same as below
69
- ### else
70
- ### 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
71
86
  exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Ruby::BACKEND_RUN))
72
87
  pid = Kernel.spawn(opts[:libs_preloaderrun] + ' ' + exe , :pgroup => true, :in => '/dev/null', :out => exe + '.out', :err => exe + '.err')
73
88
  Process.detach pid
74
89
  File.write(exe + '.pid',pid)
75
- ### end
90
+ end
76
91
  end
77
92
 
78
93
  def self::stop(id,opts) ### return: bool to tell if manually changing redis is necessary
79
- exe = File.join(opts[:instances],id.to_s,File.basename(ExecutionHandler::Ruby::BACKEND_RUN))
80
- pid = File.read(exe + '.pid') rescue nil
81
- if pid && (Process.kill(0, pid.to_i) rescue false)
82
- Process.kill('HUP', pid.to_i) rescue nil
83
- false
84
- else # its not running, so clean up
85
- File.unlink(exe + '.pid') rescue nil
86
- 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
87
117
  end
88
118
  end
89
119
  end
@@ -1 +1 @@
1
- 383733
1
+ 601746
@@ -1 +1 @@
1
- 383775
1
+ 601788
@@ -1 +1 @@
1
- 383761
1
+ 601774
@@ -1 +1 @@
1
- 383747
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.103
4
+ version: 2.1.106
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
@@ -986,6 +986,7 @@ files:
986
986
  - lib/callbacks/callbacks.rng
987
987
  - lib/cpee.xml
988
988
  - lib/cpee/attributes_helper.rb
989
+ - lib/cpee/constants.rb
989
990
  - lib/cpee/fail.rb
990
991
  - lib/cpee/implementation.rb
991
992
  - lib/cpee/implementation_callbacks.rb