cpee-instantiation 1.0.18 → 1.0.24

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: 025e4ba070e685921b00e57887d8f979a3d6434b74b16efbaa6adb310534a7d7
4
- data.tar.gz: 9a84e081c68f000c4519054a116b9caa93ce5f7f1920dd88f993478ef1f86a01
3
+ metadata.gz: 2b92cd471892d3eef55e68e3684b33cdeab451ca7844cc381a220fe10dd62e7a
4
+ data.tar.gz: bb7ac9554eb9226c37c77937da6f32afe9b21187db9bef9a2b8460c90b03d086
5
5
  SHA512:
6
- metadata.gz: d1d447f2bbc430412f369f267ff3b1078d299e65f3613b5a1b40e79b8964ec864ccb8690c8db19bf329a970b5fda8951cfb569b91dd9d2caf442d1d8b7ede905
7
- data.tar.gz: '0692514bb3af3b5162d0d7b8d1f97fecc1a1ff04556f5e78cf282f035829e7e307b00636e5b43aeac1a2f6f5d55cf188286144bbabf7b20e37d1093695706648'
6
+ metadata.gz: ea47cf96378fbd39c8661a7c1e5054d193a662deac7626e80777ebedbf8eb41520a17c734167581d9257946073cf6cc8b1d3efde4f1b895fff51d44c9768cbbe
7
+ data.tar.gz: fcf4c3d6c298531f2cad59d75b4144cd618d17597f32bde9f52ae88959a120ce3d3c2873495a30cb76771b1554ca33fdf0c06bd0c10fa2863f37933b6ce61547
data/README.md CHANGED
@@ -4,7 +4,7 @@ To install the instatiation service go to the commandline
4
4
 
5
5
  ```bash
6
6
  gem install cpee-instantiation
7
- cpee-instantiation instantiation
7
+ cpee-instantiation new instantiation
8
8
  cd instantiation
9
9
  ./instantiation start
10
10
  ```
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-instantiation"
3
- s.version = "1.0.18"
3
+ s.version = "1.0.24"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "Subprocess instantiation service for the cloud process execution engine (cpee.org)"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.email = 'juergen.mangler@gmail.com'
21
21
  s.homepage = 'http://cpee.org/'
22
22
 
23
- s.add_runtime_dependency 'riddl', '~> 0.99'
23
+ s.add_runtime_dependency 'riddl', '~> 1.0'
24
24
  s.add_runtime_dependency 'json', '~> 2.1'
25
25
  s.add_runtime_dependency 'redis', '~> 5.0'
26
26
  s.add_runtime_dependency 'cpee', '~> 2.1', '>= 2.1.4'
@@ -1,21 +1,22 @@
1
1
  # This file is part of CPEE-INSTANTIATION.
2
2
  #
3
3
  # CPEE-INSTANTIATION is free software: you can redistribute it and/or modify it
4
- # under the terms of the GNU General Public License as published by the Free
5
- # Software Foundation, either version 3 of the License, or (at your option) any
6
- # later version.
4
+ # under the terms of the GNU Lesser General Public License as published by the
5
+ # Free Software Foundation, either version 3 of the License, or (at your
6
+ # option) any later version.
7
7
  #
8
8
  # CPEE-INSTANTIATION is distributed in the hope that it will be useful, but
9
9
  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- # more details.
10
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11
+ # for more details.
12
12
  #
13
- # You should have received a copy of the GNU General Public License along with
14
- # CPEE-INSTANTIATION (file LICENSE in the main directory). If not, see
15
- # <http://www.gnu.org/licenses/>.
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # along with CPEE-INSTANTIATION (file LICENSE in the main directory). If not,
15
+ # see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  require 'rubygems'
18
18
  require 'cpee/value_helper'
19
+ require 'cpee/redis'
19
20
  require 'xml/smart'
20
21
  require 'riddl/server'
21
22
  require 'securerandom'
@@ -24,6 +25,8 @@ require 'uri'
24
25
  require 'redis'
25
26
  require 'json'
26
27
 
28
+ require_relative 'utils'
29
+
27
30
  module CPEE
28
31
  module Instantiation
29
32
 
@@ -38,7 +41,12 @@ module CPEE
38
41
  ele.first.text = CPEE::ValueHelper::generate(v)
39
42
  else
40
43
  ele = tdoc.find("/*/prop:#{what}")
41
- ele.first.add(k,CPEE::ValueHelper::generate(v)) if ele.any?
44
+ ele = if ele.any?
45
+ ele.first
46
+ else
47
+ tdoc.root.add("prop:#{what}")
48
+ end
49
+ ele.add(k,CPEE::ValueHelper::generate(v))
42
50
  end
43
51
  end
44
52
  end
@@ -283,15 +291,18 @@ module CPEE
283
291
  end
284
292
  end #}}}
285
293
 
286
- class InstantiateXML < Riddl::Implementation #{{{
294
+ class InstantiateXML < Riddl::Implementation #{{{
287
295
  include Helpers
288
296
 
289
297
  def response
298
+ puts "InstantiateXML response method called: #{@a[1]}",
290
299
  cpee = @h['X_CPEE'] || @a[0]
291
300
  behavior = @a[1] ? 'fork_ready' : @p[0].value
292
301
  data = @a[1] ? 0 : 1
293
302
  selfurl = @a[2]
294
303
  cblist = @a[3]
304
+ puts "Received data: #{@p}"
305
+ puts "p[data]: #{@p[data]}"
295
306
  tdoc = if @p[data].additional =~ /base64/
296
307
  Base64.decode64(@p[data].value.read)
297
308
  else
@@ -316,6 +327,7 @@ module CPEE
316
327
  if @p[0].value =~ /^wait/
317
328
  @headers << Riddl::Header.new('CPEE-CALLBACK','true')
318
329
  end
330
+ @headers << Riddl::Header.new('CPEE-INSTANTIATION',JSON::generate(send))
319
331
  Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
320
332
  end
321
333
  end
@@ -400,33 +412,54 @@ module CPEE
400
412
  ]
401
413
  end
402
414
  end
403
- end #}}}
415
+
416
+ end #}}}
404
417
 
405
418
  def self::implementation(opts)
406
419
  opts[:cpee] ||= 'http://localhost:9298/'
407
- opts[:redis_path] ||= '/tmp/redis.sock'
408
- opts[:redis_db] ||= 14
409
420
  opts[:self] ||= "http#{opts[:secure] ? 's' : ''}://#{opts[:host]}:#{opts[:port]}/"
410
- opts[:cblist] = Redis.new(path: opts[:redis_path], db: opts[:redis_db])
421
+
422
+ opts[:watchdog_frequency] ||= 7
423
+ opts[:watchdog_start_off] ||= false
424
+
425
+ ### set redis_cmd to nil if you want to do global
426
+ ### at least redis_path or redis_url and redis_db have to be set if you do global
427
+ opts[:redis_path] ||= 'redis.sock' # use e.g. /tmp/redis.sock for global stuff. Look it up in your redis config
428
+ opts[:redis_db] ||= 0
429
+ ### optional redis stuff
430
+ opts[:redis_url] ||= nil
431
+ opts[:redis_cmd] ||= 'redis-server --port 0 --unixsocket #redis_path# --unixsocketperm 600 --pidfile #redis_pid# --dir #redis_db_dir# --dbfilename #redis_db_name# --databases 1 --save 900 1 --save 300 10 --save 60 10000 --rdbcompression yes --daemonize yes'
432
+ opts[:redis_pid] ||= 'redis.pid' # use e.g. /var/run/redis.pid if you do global. Look it up in your redis config
433
+ opts[:redis_db_name] ||= 'redis.rdb' # use e.g. /var/lib/redis.rdb for global stuff. Look it up in your redis config
434
+
435
+ CPEE::redis_connect opts, 'Instantiation'
436
+
411
437
  Proc.new do
438
+ parallel do
439
+ CPEE::Instantiation::watch_services(opts[:watchdog_start_off],opts[:redis_url],File.join(opts[:basepath],opts[:redis_path]),opts[:redis_db])
440
+ EM.add_periodic_timer(opts[:watchdog_frequency]) do ### start services
441
+ CPEE::Instantiation::watch_services(opts[:watchdog_start_off],opts[:redis_url],File.join(opts[:basepath],opts[:redis_path]),opts[:redis_db])
442
+ end
443
+ end
444
+
412
445
  on resource do
413
446
  run InstantiateXML, opts[:cpee], true if post 'xmlsimple'
414
447
  on resource 'xml' do
415
448
  run InstantiateXML, opts[:cpee], false if post 'xml'
416
449
  end
417
450
  on resource 'url' do
418
- run InstantiateUrl, opts[:cpee], opts[:self], opts[:cblist], false if post 'url'
419
- run InstantiateUrl, opts[:cpee], opts[:self], opts[:cblist], true if post 'url_info'
451
+ run InstantiateUrl, opts[:cpee], opts[:self], opts[:redis], false if post 'url'
452
+ run InstantiateUrl, opts[:cpee], opts[:self], opts[:redis], true if post 'url_info'
420
453
  end
421
454
  on resource 'git' do
422
- run InstantiateGit, opts[:cpee], opts[:self], opts[:cblist] if post 'git'
455
+ run InstantiateGit, opts[:cpee], opts[:self], opts[:redis] if post 'git'
423
456
  end
424
457
  on resource 'instance' do
425
- run HandleInstance, opts[:cpee], opts[:self], opts[:cblist] if post 'instance'
458
+ run HandleInstance, opts[:cpee], opts[:self], opts[:redis] if post 'instance'
426
459
  end
427
460
  on resource 'callback' do
428
461
  on resource do
429
- run ContinueTask, opts[:cpee], opts[:cblist] if post
462
+ run ContinueTask, opts[:cpee], opts[:redis] if post
430
463
  end
431
464
  end
432
465
  end
@@ -1,3 +1,21 @@
1
+ <!--
2
+ This file is part of CPEE-INSTANTIATION.
3
+
4
+ CPEE-INSTANTIATION is free software: you can redistribute it and/or modify it
5
+ under the terms of the GNU Lesser General Public License as published by the
6
+ Free Software Foundation, either version 3 of the License, or (at your
7
+ option) any later version.
8
+
9
+ CPEE-INSTANTIATION is distributed in the hope that it will be useful, but
10
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
12
+ for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with CPEE-INSTANTIATION (file LICENSE in the main directory). If not,
16
+ see <http://www.gnu.org/licenses/>.
17
+ -->
18
+
1
19
  <description datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns="http://riddl.org/ns/description/1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
2
20
  <message name="xmlsimple">
3
21
  <parameter name="xml" mimetype="*/xml"/>
@@ -0,0 +1,52 @@
1
+ # This file is part of CPEE-INSTANTIATION
2
+ #
3
+ # CPEE-INSTANTIATION is free software: you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as published by the
5
+ # Free Software Foundation, either version 3 of the License, or (at your
6
+ # option) any later version.
7
+ #
8
+ # CPEE-INSTANTIATION is distributed in the hope that it will be useful, but WITHOUT
9
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11
+ # details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # along with CPEE-INSTANTIATION (file LICENSE in the main directory). If not, see
15
+ # <http://www.gnu.org/licenses/>.
16
+
17
+ module CPEE
18
+ module Instantiation
19
+
20
+ def self::watch_services(watchdog_start_off,url,path,db)
21
+ return if watchdog_start_off
22
+ EM.defer do
23
+ Dir[File.join(__dir__,'routing','*.rb')].each do |s|
24
+ s = s.sub(/\.rb$/,'')
25
+ pid = (File.read(s + '.pid').to_i rescue nil)
26
+ cmd = if url.nil?
27
+ "-p \"#{path}\" -d #{db} restart"
28
+ else
29
+ "-u \"#{url}\" -d #{db} restart"
30
+ end
31
+ if (pid.nil? || !(Process.kill(0, pid) rescue false)) && !File.exist?(s + '.lock')
32
+ system "#{s}.rb " + cmd + " 1>/dev/null 2>&1"
33
+ puts "➡ Service #{File.basename(s)} (-v #{cmd}) started ..."
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def self::cleanup_services(watchdog_start_off)
40
+ return if watchdog_start_off
41
+ Dir[File.join(__dir__,'routing','*.rb')].each do |s|
42
+ s = s.sub(/\.rb$/,'')
43
+ pid = (File.read(s + '.pid').to_i rescue nil)
44
+ if !pid.nil? || (Process.kill(0, pid) rescue false)
45
+ system "#{s}.rb stop 1>/dev/null 2>&1"
46
+ puts "➡ Service #{File.basename(s,'.rb')} stopped ..."
47
+ end
48
+ end
49
+ end
50
+
51
+ end
52
+ end
data/server/instantiation CHANGED
@@ -1,4 +1,21 @@
1
1
  #!/usr/bin/ruby
2
+ #
3
+ # This file is part of CPEE-INSTANTIATION.
4
+ #
5
+ # CPEE-INSTANTIATION is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU General Public License as published by the Free
7
+ # Software Foundation, either version 3 of the License, or (at your option) any
8
+ # later version.
9
+ #
10
+ # CPEE-INSTANTIATION is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
+ # more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along with
16
+ # CPEE-INSTANTIATION (file LICENSE in the main directory). If not, see
17
+ # <http://www.gnu.org/licenses/>.
18
+
2
19
  require 'rubygems'
3
20
  require 'cpee-instantiation/instantiation'
4
21
 
@@ -1,4 +1,21 @@
1
1
  #!/usr/bin/ruby
2
+ #
3
+ # This file is part of CPEE-INSTANTIATION.
4
+ #
5
+ # CPEE-INSTANTIATION is free software: you can redistribute it and/or modify it
6
+ # under the terms of the GNU General Public License as published by the Free
7
+ # Software Foundation, either version 3 of the License, or (at your option) any
8
+ # later version.
9
+ #
10
+ # CPEE-INSTANTIATION is distributed in the hope that it will be useful, but
11
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
+ # more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License along with
16
+ # CPEE-INSTANTIATION (file LICENSE in the main directory). If not, see
17
+ # <http://www.gnu.org/licenses/>.
18
+
2
19
  curpath = __dir__
3
20
  require 'rubygems'
4
21
  require 'optparse'
@@ -26,24 +43,28 @@ end
26
43
  ARGV.options { |opt|
27
44
  opt.summary_indent = ' ' * 2
28
45
  opt.summary_width = 15
29
- opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [DIR]\n"
46
+ opt.banner = "Usage:\n#{opt.summary_indent}#{File.basename($0)} [options] new DIR\n"
30
47
  opt.on("Options:")
31
48
  opt.on("--help", "-h", "This text") { puts opt; exit }
32
49
  opt.on("")
33
- opt.on(wrap("[DIR] scaffolds a sample instantiation service. Post a testset to a model to keep going in one operation."))
50
+ opt.on(wrap("[new DIR] scaffolds a sample instantiation service. Post a testset to a model to keep going in one operation."))
34
51
  opt.parse!
35
52
  }
36
- if (ARGV.length != 1)
53
+ if (ARGV.length < 2) ||
54
+ (ARGV.length == 2 && !(%w(new).include?(ARGV[0]))) ||
55
+ (ARGV.length > 2)
37
56
  puts ARGV.options
38
57
  exit
39
- else
40
- p1 = ARGV[0]
41
58
  end
59
+ command = ARGV[0]
60
+ p1 = ARGV[1]
42
61
 
43
- insta = "#{curpath}/../server/"
44
- if !File.exist?(p1)
45
- FileUtils.cp_r(insta,p1)
46
- else
47
- FileUtils.cp_r(Dir.glob(File.join(insta,'*')).delete_if{|e| e =~ /\.conf/ },p1,remove_destination: true)
48
- puts 'Directory already exists, updating ...'
62
+ if command == 'new'
63
+ insta = "#{curpath}/../server/"
64
+ if !File.exist?(p1)
65
+ FileUtils.cp_r(insta,p1)
66
+ else
67
+ FileUtils.cp_r(Dir.glob(File.join(insta,'*')).delete_if{|e| e =~ /\.conf/ },p1,remove_destination: true)
68
+ puts 'Directory already exists, updating ...'
69
+ end
49
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-instantiation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.18
4
+ version: 1.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: tools
11
11
  cert_chain: []
12
- date: 2023-04-21 00:00:00.000000000 Z
12
+ date: 2025-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riddl
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0.99'
20
+ version: '1.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '0.99'
27
+ version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: json
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +88,7 @@ files:
88
88
  - cpee-instantiation.gemspec
89
89
  - lib/cpee-instantiation/instantiation.rb
90
90
  - lib/cpee-instantiation/instantiation.xml
91
+ - lib/cpee-instantiation/utils.rb
91
92
  - server/instantiation
92
93
  - tools/cpee-instantiation
93
94
  homepage: http://cpee.org/
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  - !ruby/object:Gem::Version
110
111
  version: '0'
111
112
  requirements: []
112
- rubygems_version: 3.3.26
113
+ rubygems_version: 3.5.22
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: Subprocess instantiation service for the cloud process execution engine (cpee.org)