cpee-instantiation 1.0.20 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 520885171160a30e9ba87160846e940e97da32bb395bbf09ca4daae72b88ccf4
4
- data.tar.gz: 33880deb6b584c9cba12efe45bc1399ff579350f67fd3f9eb1687b4582eb864e
3
+ metadata.gz: c4bcaada2f94288fb474c05aa57efd0ccc51920f7b4a877f6baac3ee9a52106c
4
+ data.tar.gz: 234e40846f6fd47f1eda15737e5b5c39aaa83627a9b305e0a8f900df344c4b3f
5
5
  SHA512:
6
- metadata.gz: 3693958d8ac8788ba324f2f52e60427dff7604316bdba46e85ddfcba494c53e061b085d0d5288e2984353fac1de2349ce6c717250c3e835d2a83934fef1875a2
7
- data.tar.gz: 321bafce9e4dd5f9293bfa3923c7db011f1631b97ac7c4222db8a2f6a740a67d50026f08789172c756585a6500f1200e4b7d7a317fd963a4094e895f098ce5b8
6
+ metadata.gz: e15606a4a56063d3004fe4bf9aa954509ccfebc771fb8cede8319b1847941886214ed7cc309ec501463c74092f8376eaf4a88100fb2cecad0b0a17ea057430cf
7
+ data.tar.gz: 3a134b1a185a3a0c95f34143a7224be55fb220db21971db21ad13befb7d16d05aebbf4fe39f7000bf7163cc6c530e5a4f8d9dcccf038894434f21df88e284eb4
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.20"
3
+ s.version = "1.0.22"
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)"
@@ -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
 
@@ -288,15 +291,18 @@ module CPEE
288
291
  end
289
292
  end #}}}
290
293
 
291
- class InstantiateXML < Riddl::Implementation #{{{
294
+ class InstantiateXML < Riddl::Implementation #{{{
292
295
  include Helpers
293
296
 
294
297
  def response
298
+ puts "InstantiateXML response method called: #{@a[1]}",
295
299
  cpee = @h['X_CPEE'] || @a[0]
296
300
  behavior = @a[1] ? 'fork_ready' : @p[0].value
297
301
  data = @a[1] ? 0 : 1
298
302
  selfurl = @a[2]
299
303
  cblist = @a[3]
304
+ puts "Received data: #{@p}"
305
+ puts "p[data]: #{@p[data]}"
300
306
  tdoc = if @p[data].additional =~ /base64/
301
307
  Base64.decode64(@p[data].value.read)
302
308
  else
@@ -405,15 +411,36 @@ module CPEE
405
411
  ]
406
412
  end
407
413
  end
408
- end #}}}
414
+
415
+ end #}}}
409
416
 
410
417
  def self::implementation(opts)
411
418
  opts[:cpee] ||= 'http://localhost:9298/'
412
- opts[:redis_path] ||= '/tmp/redis.sock'
413
- opts[:redis_db] ||= 14
414
419
  opts[:self] ||= "http#{opts[:secure] ? 's' : ''}://#{opts[:host]}:#{opts[:port]}/"
415
- opts[:cblist] = Redis.new(path: opts[:redis_path], db: opts[:redis_db])
420
+
421
+ opts[:watchdog_frequency] ||= 7
422
+ opts[:watchdog_start_off] ||= false
423
+
424
+ ### set redis_cmd to nil if you want to do global
425
+ ### at least redis_path or redis_url and redis_db have to be set if you do global
426
+ opts[:redis_path] ||= 'redis.sock' # use e.g. /tmp/redis.sock for global stuff. Look it up in your redis config
427
+ opts[:redis_db] ||= 0
428
+ ### optional redis stuff
429
+ opts[:redis_url] ||= nil
430
+ 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'
431
+ opts[:redis_pid] ||= 'redis.pid' # use e.g. /var/run/redis.pid if you do global. Look it up in your redis config
432
+ opts[:redis_db_name] ||= 'redis.rdb' # use e.g. /var/lib/redis.rdb for global stuff. Look it up in your redis config
433
+
434
+ opts[:cblist] = CPEE::redis_connect opts, 'Instantiation'
435
+
416
436
  Proc.new do
437
+ parallel do
438
+ CPEE::Instantiation::watch_services(opts[:watchdog_start_off],opts[:redis_url],File.join(opts[:basepath],opts[:redis_path]),opts[:redis_db])
439
+ EM.add_periodic_timer(opts[:watchdog_frequency]) do ### start services
440
+ CPEE::Instantiation::watch_services(opts[:watchdog_start_off],opts[:redis_url],File.join(opts[:basepath],opts[:redis_path]),opts[:redis_db])
441
+ end
442
+ end
443
+
417
444
  on resource do
418
445
  run InstantiateXML, opts[:cpee], true if post 'xmlsimple'
419
446
  on resource 'xml' do
@@ -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.20
4
+ version: 1.0.22
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: 2024-06-27 00:00:00.000000000 Z
12
+ date: 2024-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riddl
@@ -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/