cpee-instantiation 1.0.21 → 1.0.22

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: 48b61fe23e043cfed4157b397aa1af88953fa552533af459799e5171f30a98fa
4
- data.tar.gz: 6b88eecca4869e1b98bab5c3f3d85196817682a1e916abb668f707498b1ea53c
3
+ metadata.gz: c4bcaada2f94288fb474c05aa57efd0ccc51920f7b4a877f6baac3ee9a52106c
4
+ data.tar.gz: 234e40846f6fd47f1eda15737e5b5c39aaa83627a9b305e0a8f900df344c4b3f
5
5
  SHA512:
6
- metadata.gz: 3e741fd88a4e9409523dc96754ab15d7d1236bc82239f487fce88e4d8d58e6a0ea00928928adb921e291bbf4e7832da1f23d1dc56ba16c0345c1e3d9c5d3966c
7
- data.tar.gz: 44e0644281f0dffcd8e143549513563d0cce7d34f481299b0e9ed60050f6a2e4417a39384f63fafc4c9a4e4fffa5cd555e65397a041b239f65144ada56529de2
6
+ metadata.gz: e15606a4a56063d3004fe4bf9aa954509ccfebc771fb8cede8319b1847941886214ed7cc309ec501463c74092f8376eaf4a88100fb2cecad0b0a17ea057430cf
7
+ data.tar.gz: 3a134b1a185a3a0c95f34143a7224be55fb220db21971db21ad13befb7d16d05aebbf4fe39f7000bf7163cc6c530e5a4f8d9dcccf038894434f21df88e284eb4
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-instantiation"
3
- s.version = "1.0.21"
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'
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.21
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-07-02 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/