cpee-model-management 1.2.6 → 1.2.7
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 +4 -4
- data/cpee-model-management.gemspec +2 -2
- data/lib/cpee-model-management/dashing.rb +30 -0
- data/lib/cpee-model-management/{moma.xml → dashing.xml} +1 -7
- data/lib/cpee-model-management/implementation.rb +53 -29
- data/server/moma +7 -2
- data/server/moma.conf +1 -0
- data/ui/js/stats.js +9 -9
- metadata +9 -3
- data/server/redis.rdb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da8a1393a981789476307ef0e613545dc263312cc059d6660fb532ec89f01e4d
|
|
4
|
+
data.tar.gz: 810b7bd624babce546318e16ed0c1dda2a46332dcbb8968640db0fc0c6679e23
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15fbcfa24d65bae3f763963726664b74bdae9b5c4843f1121e21bd65dd78448a3325607a880483e04e046c76556ff66c7d956a857345992301c4ba1bd67943e9
|
|
7
|
+
data.tar.gz: f1836da53235376adeaef4186be11803b605a2e2f76f2bfaad71991be020bdc3663a627769f7ba7eca08d5c4246879c5430bc8beaabc93989e6ff62782eb59c7
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "cpee-model-management"
|
|
3
|
-
s.version = "1.2.
|
|
3
|
+
s.version = "1.2.7"
|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
|
5
5
|
s.license = "LGPL-3.0"
|
|
6
6
|
s.summary = "(Lifecycle) manage your process models in a directory or git repo."
|
|
@@ -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', '~> 1.0'
|
|
23
|
+
s.add_runtime_dependency 'riddl', '~> 1.0', '>=1.0.12'
|
|
24
24
|
s.add_runtime_dependency 'json', '~> 2.1'
|
|
25
25
|
s.add_runtime_dependency 'cpee', '~> 2.1', '>= 2.1.114'
|
|
26
26
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
require_relative 'implementation'
|
|
3
|
+
|
|
4
|
+
options = {
|
|
5
|
+
:host => 'localhost',
|
|
6
|
+
:port => 9317,
|
|
7
|
+
:secure => false
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Riddl::Server.new(File.join(__dir__,'dashing.xml'), options) do |opts|
|
|
11
|
+
accessible_description true
|
|
12
|
+
cross_site_xhr true
|
|
13
|
+
|
|
14
|
+
### set redis_cmd to nil if you want to do global
|
|
15
|
+
### at least redis_path or redis_url and redis_db have to be set if you do global
|
|
16
|
+
opts[:redis_db] ||= 0
|
|
17
|
+
opts[:redis_url] ||= 'unix://redis.sock' # sadly we have to do this for now
|
|
18
|
+
opts[:redis_unixsocket] ||= true
|
|
19
|
+
opts[:redis_cmd] ||= 'redis-server --port #redis_port# --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 --protected-mode no'
|
|
20
|
+
opts[:redis_pid] ||= 'redis.pid' # use e.g. /var/run/redis.pid if you do global. Look it up in your redis config
|
|
21
|
+
opts[:redis_db_name] ||= 'redis.rdb' # use e.g. /var/lib/redis.rdb for global stuff. Look it up in your redis config
|
|
22
|
+
|
|
23
|
+
startup do
|
|
24
|
+
CPEE::redis_connect opts, 'Server Main'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
interface 'events' do
|
|
28
|
+
run CPEE::ModelManagement::StatReceive, opts[:redis], opts[:stat_receivers] if post 'event'
|
|
29
|
+
end
|
|
30
|
+
end.loop!
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
<declaration xmlns="http://riddl.org/ns/declaration/1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
2
|
-
<interface name="implementation">
|
|
3
|
-
<xi:include href="implementation.xml"/>
|
|
4
|
-
</interface>
|
|
5
2
|
<interface name="events">
|
|
6
3
|
<xi:include href="http://www.riddl.org/ns/common-patterns/notifications-consumer/2.0/consumer.xml"/>
|
|
7
4
|
</interface>
|
|
8
5
|
|
|
9
6
|
<facade>
|
|
10
7
|
<tile>
|
|
11
|
-
<layer name="implementation">
|
|
12
|
-
<apply-to>/</apply-to>
|
|
13
|
-
</layer>
|
|
14
8
|
<layer name="events">
|
|
15
|
-
<apply-to
|
|
9
|
+
<apply-to>/</apply-to>
|
|
16
10
|
</layer>
|
|
17
11
|
</tile>
|
|
18
12
|
</facade>
|
|
@@ -31,7 +31,7 @@ require 'digest/sha1'
|
|
|
31
31
|
module CPEE
|
|
32
32
|
module ModelManagement
|
|
33
33
|
|
|
34
|
-
SERVER = File.expand_path(File.join(__dir__,'
|
|
34
|
+
SERVER = File.expand_path(File.join(__dir__,'implementation.xml'))
|
|
35
35
|
|
|
36
36
|
def self::git_mv(models,old,new)
|
|
37
37
|
cdir = Dir.pwd
|
|
@@ -299,7 +299,7 @@ module CPEE
|
|
|
299
299
|
end
|
|
300
300
|
File.write(fname + '.attrs',JSON::pretty_generate(attrs))
|
|
301
301
|
|
|
302
|
-
CPEE::ModelManagement::op author, 'mv', models, File.join('.', where,
|
|
302
|
+
CPEE::ModelManagement::op author, 'mv', models, File.join('.', where, File.basename(fnname)), File.join('.', where, name + '.xml')
|
|
303
303
|
CPEE::ModelManagement::notify conns, 'rename', models, fnname, fname
|
|
304
304
|
nil
|
|
305
305
|
end
|
|
@@ -330,7 +330,7 @@ module CPEE
|
|
|
330
330
|
XML::Smart::modify(f) do |doc|
|
|
331
331
|
doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
|
|
332
332
|
doc.find('/p:testset/p:attributes/p:design_dir').each do |ele|
|
|
333
|
-
ele.text =
|
|
333
|
+
ele.text = File.basename(fnname,'.dir')
|
|
334
334
|
end
|
|
335
335
|
attrs = doc.find('/p:testset/p:attributes/*').map do |e|
|
|
336
336
|
[e.qname.name,e.text]
|
|
@@ -339,7 +339,7 @@ module CPEE
|
|
|
339
339
|
File.write(f + '.attrs',JSON::pretty_generate(attrs))
|
|
340
340
|
end
|
|
341
341
|
|
|
342
|
-
CPEE::ModelManagement::op author, 'mv', models, File.
|
|
342
|
+
CPEE::ModelManagement::op author, 'mv', models, File.basename(fnname), name + '.dir'
|
|
343
343
|
CPEE::ModelManagement::notify conns, 'rename', models, fnname, fname
|
|
344
344
|
nil
|
|
345
345
|
end
|
|
@@ -667,7 +667,6 @@ module CPEE
|
|
|
667
667
|
class StatReceive < Riddl::Implementation #{{{
|
|
668
668
|
def response
|
|
669
669
|
redis = @a[0]
|
|
670
|
-
receivers = @a[1]
|
|
671
670
|
topic = @p[1].value
|
|
672
671
|
event_name = @p[2].value
|
|
673
672
|
notification = JSON.parse(@p[3].value.read)
|
|
@@ -734,13 +733,16 @@ module CPEE
|
|
|
734
733
|
end
|
|
735
734
|
end
|
|
736
735
|
elsif %w{stopped}.include?(content['state'])
|
|
737
|
-
redis.
|
|
738
|
-
|
|
739
|
-
multi
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
736
|
+
oldstate = redis.get(File.join(prefix,'state'))
|
|
737
|
+
if oldstate && oldstate != 'stopped' # stopped can be repeated when reloading instance, any other state before is either fine or can not happen
|
|
738
|
+
redis.multi do |multi|
|
|
739
|
+
multi.decr(File.join(engine,'running'))
|
|
740
|
+
multi.incr(File.join(engine,'stopped'))
|
|
741
|
+
multi.set(File.join(prefix,'state'),content['state'])
|
|
742
|
+
multi.set(File.join(prefix,'cpu'),0)
|
|
743
|
+
multi.set(File.join(prefix,'mem'),0)
|
|
744
|
+
multi.set(File.join(prefix,'time'),Time.now.to_i)
|
|
745
|
+
end
|
|
744
746
|
end
|
|
745
747
|
elsif %w{running}.include?(content['state'])
|
|
746
748
|
oldstate = redis.get(File.join(prefix,'state'))
|
|
@@ -762,9 +764,7 @@ module CPEE
|
|
|
762
764
|
File.join(prefix,'time'),
|
|
763
765
|
File.join(prefix,'parent')
|
|
764
766
|
)
|
|
765
|
-
|
|
766
|
-
conn.send JSON::generate(:topic => topic, :event => event_name, :engine => engine, :uuid => notification['instance-uuid'], :url => url, :author => author, :path => path.to_s, :name => name, :state => content['state'], :time => time, :parent => parent.to_s)
|
|
767
|
-
end
|
|
767
|
+
redis.publish 'forward', JSON::generate(:topic => topic, :event => event_name, :engine => engine, :uuid => notification['instance-uuid'], :url => url, :author => author, :path => path.to_s, :name => name, :state => content['state'], :time => time, :parent => parent.to_s)
|
|
768
768
|
elsif topic == 'task' && event_name == 'instantiation'
|
|
769
769
|
redis.multi do |multi|
|
|
770
770
|
multi.rpush(File.join(engine,notification['instance-uuid'],'children'),content['received']['CPEE-INSTANCE-UUID'])
|
|
@@ -780,18 +780,14 @@ module CPEE
|
|
|
780
780
|
File.join(prefix,'time'),
|
|
781
781
|
File.join(prefix,'parent')
|
|
782
782
|
)
|
|
783
|
-
|
|
784
|
-
conn.send JSON::generate(:topic => 'state', :event => 'change', :engine => engine, :uuid => content['received']['CPEE-INSTANCE-UUID'], :url => url, :author => author, :path => path.to_s, :name => name, :state => state, :time => time, :parent => parent.to_s)
|
|
785
|
-
end
|
|
783
|
+
redis.publish 'forward', JSON::generate(:topic => 'state', :event => 'change', :engine => engine, :uuid => content['received']['CPEE-INSTANCE-UUID'], :url => url, :author => author, :path => path.to_s, :name => name, :state => state, :time => time, :parent => parent.to_s)
|
|
786
784
|
elsif topic == 'status' && event_name == 'resource_utilization'
|
|
787
785
|
redis.multi do |multi|
|
|
788
786
|
multi.set(File.join(prefix,'name'),attr['info'])
|
|
789
787
|
multi.set(File.join(prefix,'cpu'),content['utime'] + content['stime'])
|
|
790
788
|
multi.set(File.join(prefix,'mem'),content['mib'])
|
|
791
789
|
end
|
|
792
|
-
|
|
793
|
-
conn.send JSON::generate(:topic => topic, :event => event_name, :engine => engine, :uuid => notification['instance-uuid'], :cpu => content['utime'] + content['stime'], :mem => content['mib'])
|
|
794
|
-
end
|
|
790
|
+
redis.publish 'forward', JSON::generate(:topic => topic, :event => event_name, :engine => engine, :uuid => notification['instance-uuid'], :cpu => content['utime'] + content['stime'], :mem => content['mib'])
|
|
795
791
|
elsif topic == 'node' && event_name == 'resource_utilization'
|
|
796
792
|
redis.multi do |multi|
|
|
797
793
|
multi.set(File.join(engine,'cpu_usage'),content['cpu_usage'])
|
|
@@ -799,9 +795,7 @@ module CPEE
|
|
|
799
795
|
multi.set(File.join(engine,'mem_total'),content['mem_total'])
|
|
800
796
|
multi.set(File.join(engine,'mem_available'),content['mem_available'])
|
|
801
797
|
end
|
|
802
|
-
|
|
803
|
-
conn.send JSON::generate(:topic => topic, :event => event_name, :engine => engine, :cpu_usage => content['cpu_usage'], :mem_free => content['mem_free'], :mem_total => content['mem_total'], :mem_available => content['mem_available'])
|
|
804
|
-
end
|
|
798
|
+
redis.publish 'forward', JSON::generate(:topic => topic, :event => event_name, :engine => engine, :cpu_usage => content['cpu_usage'], :mem_free => content['mem_free'], :mem_total => content['mem_total'], :mem_available => content['mem_available'])
|
|
805
799
|
end
|
|
806
800
|
end
|
|
807
801
|
end #}}}
|
|
@@ -866,11 +860,36 @@ module CPEE
|
|
|
866
860
|
end
|
|
867
861
|
end #}}}
|
|
868
862
|
|
|
863
|
+
def self::service_handler(opts,cmd,out) #{{{
|
|
864
|
+
1.upto opts[:workers] do |i|
|
|
865
|
+
s = File.join(__dir__,'dashing.rb')
|
|
866
|
+
next if File.exist?(s + '.lock')
|
|
867
|
+
pid = (File.read(s + '.pid').to_i rescue nil)
|
|
868
|
+
if (pid.nil? || !(Process.kill(0, pid) rescue false))
|
|
869
|
+
params = "-p #{opts[:port].to_i + i} -o basepath=#{File.realpath(opts[:basepath])} #{cmd} 1>/dev/null 2>&1"
|
|
870
|
+
system "#{s} #{params} 1>/dev/null 2>&1"
|
|
871
|
+
puts "➡ Service #{File.basename(s)} (#{params}) #{out} ..."
|
|
872
|
+
end
|
|
873
|
+
end
|
|
874
|
+
end #}}}
|
|
875
|
+
def self::sse_stat_distributor(opts) #{{{
|
|
876
|
+
conn = opts[:redis_dyn].call "Server SSE"
|
|
877
|
+
conn.subscribe('forward') do |on|
|
|
878
|
+
on.message do |what, message|
|
|
879
|
+
opts[:stat_receivers].each do |conn|
|
|
880
|
+
conn.send message
|
|
881
|
+
end
|
|
882
|
+
end
|
|
883
|
+
end
|
|
884
|
+
conn.close
|
|
885
|
+
end #}}}
|
|
869
886
|
|
|
870
887
|
def self::implementation(opts)
|
|
871
888
|
opts[:management_receivers] = []
|
|
872
889
|
opts[:stat_receivers] = []
|
|
873
890
|
|
|
891
|
+
opts[:workers] = 1
|
|
892
|
+
|
|
874
893
|
### set redis_cmd to nil if you want to do global
|
|
875
894
|
### at least redis_path or redis_url and redis_db have to be set if you do global
|
|
876
895
|
opts[:redis_db] ||= 0
|
|
@@ -880,13 +899,15 @@ module CPEE
|
|
|
880
899
|
opts[:redis_pid] ||= 'redis.pid' # use e.g. /var/run/redis.pid if you do global. Look it up in your redis config
|
|
881
900
|
opts[:redis_db_name] ||= 'redis.rdb' # use e.g. /var/lib/redis.rdb for global stuff. Look it up in your redis config
|
|
882
901
|
|
|
883
|
-
CPEE::redis_connect opts, 'Server Main'
|
|
884
|
-
|
|
885
902
|
opts[:sse_keepalive_frequency] ||= 10
|
|
886
903
|
|
|
904
|
+
CPEE::redis_connect opts, 'Server Main'
|
|
887
905
|
Proc.new do
|
|
888
906
|
|
|
889
907
|
parallel do
|
|
908
|
+
EM.defer do ### catch all sse connections
|
|
909
|
+
CPEE::ModelManagement::sse_stat_distributor(opts)
|
|
910
|
+
end
|
|
890
911
|
EM.add_periodic_timer(opts[:sse_keepalive_frequency]) do
|
|
891
912
|
opts[:management_receivers].each do |sse|
|
|
892
913
|
sse.send_with_id('heartbeat', '42') unless sse&.closed?
|
|
@@ -897,11 +918,14 @@ module CPEE
|
|
|
897
918
|
end
|
|
898
919
|
end
|
|
899
920
|
|
|
900
|
-
|
|
901
|
-
|
|
921
|
+
startup do
|
|
922
|
+
CPEE::ModelManagement::service_handler(opts,'restart','started')
|
|
923
|
+
end
|
|
924
|
+
cleanup do
|
|
925
|
+
CPEE::ModelManagement::service_handler(opts,'stop','stopped')
|
|
902
926
|
end
|
|
903
927
|
|
|
904
|
-
|
|
928
|
+
on resource do
|
|
905
929
|
run GetList, :main, opts[:views], opts[:models] if get 'stage'
|
|
906
930
|
run GetListFull, opts[:views], opts[:models] if get 'full'
|
|
907
931
|
run GetStages, opts[:themes] if get 'stages'
|
data/server/moma
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/ruby
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
if File.exist?(File.join(__dir__,'..','lib','cpee-model-management','implementation.rb'))
|
|
3
|
+
require_relative File.join(__dir__,'..','lib','cpee-model-management','implementation')
|
|
4
|
+
elsif File.exist?(File.join(Dir.home,'Projects','cpee-model-management','lib','cpee-model-management','implementation.rb'))
|
|
5
|
+
require_relative File.join(Dir.home, 'Projects','cpee-model-management','lib','cpee-model-management','implementation')
|
|
6
|
+
else
|
|
7
|
+
require 'cpee-model-management/implementation'
|
|
8
|
+
end
|
|
4
9
|
|
|
5
10
|
options = {
|
|
6
11
|
:host => 'localhost',
|
data/server/moma.conf
CHANGED
data/ui/js/stats.js
CHANGED
|
@@ -163,15 +163,15 @@ function instances_init(ename) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
function resource_paint(iname,data,count) {
|
|
166
|
-
count[iname]
|
|
167
|
-
Plotly.extendTraces('resource_utilization_plot_' + iname, {y: [[data.cpu_usage], [(data.mem_total-data.mem_available)/data.mem_total * 100]]}, [0,1])
|
|
168
|
-
Plotly.relayout('resource_utilization_plot_' + iname, {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
});
|
|
166
|
+
count[iname]++;
|
|
167
|
+
Plotly.extendTraces('resource_utilization_plot_' + iname, {y: [[data.cpu_usage], [(data.mem_total-data.mem_available)/data.mem_total * 100]]}, [0,1], value_count)
|
|
168
|
+
// Plotly.relayout('resource_utilization_plot_' + iname, {
|
|
169
|
+
// xaxis: {
|
|
170
|
+
// range: [count[iname]-value_count,count[iname]],
|
|
171
|
+
// showticklabels: false,
|
|
172
|
+
// fixedrange: true
|
|
173
|
+
// }
|
|
174
|
+
// });
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
function stats_init() {
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cpee-model-management
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juergen eTM Mangler
|
|
@@ -16,6 +16,9 @@ dependencies:
|
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
18
|
version: '1.0'
|
|
19
|
+
- - ">="
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 1.0.12
|
|
19
22
|
type: :runtime
|
|
20
23
|
prerelease: false
|
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -23,6 +26,9 @@ dependencies:
|
|
|
23
26
|
- - "~>"
|
|
24
27
|
- !ruby/object:Gem::Version
|
|
25
28
|
version: '1.0'
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: 1.0.12
|
|
26
32
|
- !ruby/object:Gem::Dependency
|
|
27
33
|
name: json
|
|
28
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -71,14 +77,14 @@ files:
|
|
|
71
77
|
- Rakefile
|
|
72
78
|
- cpee-model-management.gemspec
|
|
73
79
|
- lib/cpee-model-management/commit.rb
|
|
80
|
+
- lib/cpee-model-management/dashing.rb
|
|
81
|
+
- lib/cpee-model-management/dashing.xml
|
|
74
82
|
- lib/cpee-model-management/implementation.rb
|
|
75
83
|
- lib/cpee-model-management/implementation.xml
|
|
76
|
-
- lib/cpee-model-management/moma.xml
|
|
77
84
|
- lib/cpee-model-management/stages
|
|
78
85
|
- server/model.xml
|
|
79
86
|
- server/moma
|
|
80
87
|
- server/moma.conf
|
|
81
|
-
- server/redis.rdb
|
|
82
88
|
- server/testset.xml
|
|
83
89
|
- tools/cpee-moma
|
|
84
90
|
- ui/css/moma.css
|
data/server/redis.rdb
DELETED
|
Binary file
|