app-mgr 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -1
- data.tar.gz.sig +0 -0
- data/lib/app-mgr.rb +67 -81
- metadata +49 -27
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1b7f9478ff5a8baa6ca8fe533dd7d0ed1c2ff31
|
4
|
+
data.tar.gz: 82c38a2ae61cf314e15f8475d38c4bc7f984d2ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f680a411fe83caf47a19127138c43cf4b2db29c1973d03f0afe517e8783da6cabbae9dfc3ebf35d018867a2969ba0bf81985b7d1b07fd0270e8db75c00bfd7c4
|
7
|
+
data.tar.gz: 562307f3909b8517b739183f97f8f9e5a0d70e00bef588f6983be93e976b06870e2e519f57274695d3c5aa354a0c1b4f187d6dd39f836ba95d723ba944cc9956
|
checksums.yaml.gz.sig
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/app-mgr.rb
CHANGED
@@ -1,122 +1,108 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
3
|
# file: app-mgr.rb
|
4
|
+
|
5
|
+
require 'rscript'
|
6
|
+
|
7
|
+
|
4
8
|
class AppMgr
|
5
|
-
def initialize()
|
6
|
-
@app = {}
|
7
|
-
@content_type = 'text/xml'
|
8
|
-
super()
|
9
|
-
end
|
10
9
|
|
11
|
-
|
12
|
-
o = {name: '', object: nil, config: {}, public: {}}.merge!(opt)
|
10
|
+
attr_reader :app
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
def initialize(rsf: nil, reg: nil, rsc: nil, debug: true)
|
13
|
+
|
14
|
+
@rsf, @reg, @rsc, @debug = rsf, reg, rsc, debug
|
15
|
+
@rscript = RScript.new(type: 'app', debug: debug)
|
16
|
+
@app = {}
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
options = {public: app[:public]}
|
23
|
-
options[:config] = app[:config] unless app[:config].empty?
|
24
|
-
app[:running] = app[:object].new(options, self)
|
18
|
+
load_all(rsf)
|
19
|
+
|
20
|
+
end
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
return "app %s not available" % app_name
|
29
|
-
end
|
22
|
+
def available()
|
23
|
+
@app.select {|k,v| v[:available] == true}.keys
|
30
24
|
end
|
31
25
|
|
32
|
-
def
|
33
|
-
|
34
|
-
if app and app[:running] then
|
35
|
-
yield(app[:public])
|
36
|
-
else
|
37
|
-
return "app %s not running" % app_name
|
38
|
-
end
|
26
|
+
def call(app_name)
|
27
|
+
@app[app_name.to_sym][:running].call
|
39
28
|
end
|
40
|
-
|
41
|
-
def execute(
|
42
|
-
@app[
|
29
|
+
|
30
|
+
def execute(name, method, params='')
|
31
|
+
@app[name.to_sym][:running].method(method.to_sym).call(params)
|
43
32
|
end
|
44
33
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
34
|
+
def run(name)
|
35
|
+
|
36
|
+
app = @app[name.to_sym]
|
37
|
+
class_name = app[:code][/(?<=class )\w+/]
|
38
|
+
app[:running] = eval(class_name + '.new')
|
39
|
+
|
51
40
|
end
|
52
41
|
|
53
42
|
def running()
|
54
43
|
@app.select {|k,v| v[:running]}.keys
|
55
44
|
end
|
56
45
|
|
57
|
-
def running?(
|
58
|
-
@app[
|
46
|
+
def running?(name)
|
47
|
+
@app[name.to_sym][:running] ? true : false
|
59
48
|
end
|
60
|
-
|
61
|
-
def available()
|
62
|
-
@app.select {|k,v| v[:available] == true}.keys
|
63
|
-
end
|
64
49
|
|
65
|
-
def
|
50
|
+
def connect(name)
|
66
51
|
|
67
|
-
|
52
|
+
app = @app[name.to_sym]
|
68
53
|
|
69
|
-
if
|
70
|
-
|
71
|
-
@app.delete app_name
|
72
|
-
return "app %s unloaded" % app_name
|
54
|
+
if app and app[:running] then
|
55
|
+
yield(app[:running])
|
73
56
|
else
|
74
|
-
return "
|
57
|
+
return "app %s not running" % name
|
75
58
|
end
|
59
|
+
|
76
60
|
end
|
77
61
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
62
|
+
def stop(name)
|
63
|
+
|
64
|
+
app = @app[name.to_sym]
|
65
|
+
|
66
|
+
if app.delete(:running) then
|
67
|
+
return "app %s stopped" % name
|
82
68
|
else
|
83
|
-
return "app %s
|
69
|
+
return "couldn't find app %s" % name
|
84
70
|
end
|
71
|
+
|
85
72
|
end
|
86
73
|
|
87
|
-
|
88
|
-
def run_projectx(project_name, method_name, qparams=[])
|
74
|
+
def unload(name)
|
89
75
|
|
90
|
-
|
91
|
-
xml_project = project = "<project name='%s'><methods><method name='%s'>%s</method></methods></project>" % [project_name, method_name, params]
|
92
|
-
projectx_handler(xml_project)
|
93
|
-
end
|
76
|
+
class_name = @app[name.to_sym][:running].class.name
|
94
77
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
78
|
+
if class_name then
|
79
|
+
Object.send(:remove_const, class_name)
|
80
|
+
@app.delete name.to_sym
|
81
|
+
return "app %s unloaded" % name
|
82
|
+
else
|
83
|
+
return "couldn't find app %s" % name
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
99
87
|
|
100
|
-
|
88
|
+
private
|
101
89
|
|
102
|
-
|
103
|
-
methodx = node_method.attributes.get_attribute('name').to_s
|
104
|
-
params = node_method.elements['params'].to_s
|
90
|
+
def load_all(rsf_package)
|
105
91
|
|
106
|
-
|
107
|
-
method_out
|
108
|
-
end
|
92
|
+
@rscript.jobs(rsf_package).each do |app_name|
|
109
93
|
|
110
|
-
|
111
|
-
|
112
|
-
|
94
|
+
puts 'app_name: ' + app_name.inspect if @debug
|
95
|
+
app = @app[app_name] = {}
|
96
|
+
|
97
|
+
codeblock = @rscript.read(['//app:' + app_name.to_s, @rsf]).first
|
98
|
+
puts 'codeblock: ' + codeblock.inspect if @debug
|
99
|
+
app[:code] = codeblock
|
100
|
+
|
101
|
+
reg, rsc = @reg, @rsc
|
102
|
+
eval codeblock
|
103
|
+
|
113
104
|
end
|
114
|
-
|
115
|
-
@content_type ||= 'text/xml'
|
116
|
-
|
117
|
-
[out, @content_type]
|
105
|
+
|
118
106
|
end
|
119
107
|
|
120
|
-
|
121
108
|
end
|
122
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app-mgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,29 +10,50 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
13
|
+
MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwNzMwMjIxMjU1WhcN
|
15
|
+
MTkwNzMwMjIxMjU1WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQEOnA
|
17
|
+
GJ3ksMw8AjH3o2qGvN/2pUUV9w9BPemOxJD0A1cN9Bxiqldhq2rOasa5R7NWYJVb
|
18
|
+
XqNRzoX+ZM+o34N94Rs084bmt4UY3AIB8Qwh7b6hrPOcIMmXxvUKlTGPQmbT3xTf
|
19
|
+
0U3stPA6bSjvVoe6S1SaAufvofhPf6RK3Ha85B9rnJ6SwhXMBfefT9+46G9rg4e8
|
20
|
+
Dl5hStoXpzMvZbjRl8k+chSYIkrZRUgY2DPB4uYIGhou7pdvXz8OG44eG2emHAoP
|
21
|
+
Hq7gKRjfLEJU7Lcvuy7TW1DHQawd9fJLETF4OCe3tfmrz+paKgIGdRsBZlhcVYFi
|
22
|
+
H+CwReKpsten5B0nAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
23
|
+
HQYDVR0OBBYEFMPdyMUkpkMm4orIvKu+1K0RBEHBMCYGA1UdEQQfMB2BG2dlbW1h
|
24
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
|
25
|
+
ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBAFMKmUscAAsNitItdGmM
|
26
|
+
fER7OWnQRkNGgQQh4c0vHz4K634HXaX8Mnq76reEkbKzyeHmwFww1EV8XpkCLLjN
|
27
|
+
k7TP/AD9LJzUtXa2M3rMuLBPu98TZZvDBP/NBFXUvW6HzH77n4D2EfO+Zn/pwnb/
|
28
|
+
H47c680aCpzYPb+7x4atUtx3UGahHg6GXT5T6x+5RzCe9iNDqnC5RW6Hj9FKybsc
|
29
|
+
CiRE+GvZQcTC3EhUyHYe9A9tXqIzzaqRh3s9YdltXryzuocM/dwlT8zu4BzYKHTe
|
30
|
+
jZi4xFnZ2LNxhD09t1Ag0wOhNh+yHsyECmyU5Zu7FKG0ZNnX0zc5IAupPGBsMKXf
|
31
|
+
at4=
|
31
32
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
33
|
-
dependencies:
|
33
|
+
date: 2018-07-30 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rscript
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.3'
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.3.0
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - "~>"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0.3'
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.3.0
|
34
55
|
description:
|
35
|
-
email: james@
|
56
|
+
email: james@jamesrobertson.eu
|
36
57
|
executables: []
|
37
58
|
extensions: []
|
38
59
|
extra_rdoc_files: []
|
@@ -48,18 +69,19 @@ require_paths:
|
|
48
69
|
- lib
|
49
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
71
|
requirements:
|
51
|
-
- -
|
72
|
+
- - ">="
|
52
73
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
74
|
+
version: 2.1.2
|
54
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
76
|
requirements:
|
56
|
-
- -
|
77
|
+
- - ">="
|
57
78
|
- !ruby/object:Gem::Version
|
58
79
|
version: '0'
|
59
80
|
requirements: []
|
60
81
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.6.13
|
62
83
|
signing_key:
|
63
84
|
specification_version: 4
|
64
|
-
summary:
|
85
|
+
summary: Runs 1 or more headless apps from a kind of XML file for use in a back-end
|
86
|
+
server
|
65
87
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|