prometheus-splash 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -60
- data/bin/splash +3 -0
- data/config/splash.yml +15 -2
- data/lib/splash/backends.rb +6 -0
- data/lib/splash/backends/file.rb +36 -0
- data/lib/splash/backends/redis.rb +44 -1
- data/lib/splash/cli.rb +7 -3
- data/lib/splash/cli/commands.rb +11 -4
- data/lib/splash/cli/config.rb +9 -1
- data/lib/splash/cli/daemon.rb +8 -1
- data/lib/splash/cli/documentation.rb +5 -2
- data/lib/splash/cli/logs.rb +14 -6
- data/lib/splash/cli/process.rb +9 -0
- data/lib/splash/cli/webadmin.rb +46 -0
- data/lib/splash/commands.rb +23 -2
- data/lib/splash/config.rb +141 -1
- data/lib/splash/config/flush.rb +9 -1
- data/lib/splash/config/sanitycheck.rb +6 -1
- data/lib/splash/config/service.rb +8 -1
- data/lib/splash/config/setup.rb +8 -3
- data/lib/splash/constants.rb +30 -2
- data/lib/splash/daemon.rb +5 -1
- data/lib/splash/daemon/controller.rb +21 -1
- data/lib/splash/daemon/metrics.rb +22 -7
- data/lib/splash/daemon/orchestrator.rb +21 -3
- data/lib/splash/daemon/orchestrator/grammar.rb +25 -5
- data/lib/splash/daemon/orchestrator/hooks.rb +10 -0
- data/lib/splash/dependencies.rb +10 -1
- data/lib/splash/exiter.rb +14 -0
- data/lib/splash/helpers.rb +69 -45
- data/lib/splash/loggers.rb +30 -4
- data/lib/splash/loggers/cli.rb +18 -3
- data/lib/splash/loggers/daemon.rb +14 -3
- data/lib/splash/loggers/dual.rb +14 -1
- data/lib/splash/loggers/web.rb +51 -0
- data/lib/splash/logs.rb +15 -4
- data/lib/splash/processes.rb +17 -5
- data/lib/splash/templates.rb +10 -0
- data/lib/splash/transports.rb +9 -0
- data/lib/splash/transports/rabbitmq.rb +33 -3
- data/lib/splash/webadmin.rb +122 -0
- data/lib/splash/webadmin/api/routes/commands.rb +28 -0
- data/lib/splash/webadmin/api/routes/config.rb +10 -0
- data/lib/splash/webadmin/api/routes/init.rb +2 -0
- data/lib/splash/webadmin/api/routes/logs.rb +59 -0
- data/lib/splash/webadmin/api/routes/process.rb +60 -0
- data/lib/splash/webadmin/main.rb +26 -0
- data/lib/splash/webadmin/portal/controllers/commands.rb +7 -0
- data/lib/splash/webadmin/portal/controllers/documentation.rb +6 -0
- data/lib/splash/webadmin/portal/controllers/home.rb +12 -0
- data/lib/splash/webadmin/portal/controllers/logs.rb +14 -0
- data/lib/splash/webadmin/portal/controllers/notfound.rb +5 -0
- data/lib/splash/webadmin/portal/controllers/processes.rb +14 -0
- data/lib/splash/webadmin/portal/controllers/proxy.rb +30 -0
- data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
- data/lib/splash/webadmin/portal/init.rb +11 -0
- data/lib/splash/webadmin/portal/public/css/ultragreen.css +8544 -0
- data/lib/splash/webadmin/portal/public/fonts/FontAwesome.otf +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2 +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash.png +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash_reduce.png +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash_tiny.png +0 -0
- data/lib/splash/webadmin/portal/views/commands.slim +49 -0
- data/lib/splash/webadmin/portal/views/documentation.slim +3 -0
- data/lib/splash/webadmin/portal/views/home.slim +78 -0
- data/lib/splash/webadmin/portal/views/layout.slim +43 -0
- data/lib/splash/webadmin/portal/views/logs.slim +32 -0
- data/lib/splash/webadmin/portal/views/nav.slim +17 -0
- data/lib/splash/webadmin/portal/views/not_found.slim +3 -0
- data/lib/splash/webadmin/portal/views/processes.slim +29 -0
- data/lib/splash/webadmin/portal/views/proxy.slim +13 -0
- data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
- data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
- data/prometheus-splash.gemspec +6 -0
- data/spec/helpers_spec.rb +119 -0
- metadata +128 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54e538fd7e22b4dc38c1253db96c6e842bf81d1378db0434295c0a827e23bfb7
|
4
|
+
data.tar.gz: c951aaf9aacd398d0944594185fc8d4986de4268162a62cedd69ff0c96d26f9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 110950f5ac22753830d8b6f1fd74eaf86d77c78eb18728613215fc671279aa8c6da577ba3d54250640c747c76f35c66cd35ffd2ccb38cfc47d65a7c47e408b2b
|
7
|
+
data.tar.gz: 18aecf0d1f4f080ec1863ec79e17cc6d0582b5cd7f9efac442162c0095d92658372fa2bad1b3c502dd0e44a731a4fd9fe9710bae3e6a4d00be5759610ad08c1c
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ SPLASH is **Supervision with Prometheus of Logs and Asynchronous tasks orchestra
|
|
9
9
|
* Web : http://www.ultragreen.net
|
10
10
|
* Github : https://github.com/Ultragreen/prometheus-splash
|
11
11
|
* Rubygems : https://rubygems.org/gems/prometheus-splash
|
12
|
-
* DOC yardoc : https://www.rubydoc.info/gems/prometheus-splash/0.
|
12
|
+
* DOC yardoc : https://www.rubydoc.info/gems/prometheus-splash/0.6.0
|
13
13
|
|
14
14
|
Prometheus Logs and Batchs supervision over PushGateway
|
15
15
|
|
@@ -65,10 +65,12 @@ As root or with rvmsudo, if you use RVM.
|
|
65
65
|
# splash config setup
|
66
66
|
Splash -> setup :
|
67
67
|
* Installing Configuration file : /etc/splash.yml : [OK]
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
👍 Splash Initialisation
|
69
|
+
👍 Installing template file : /etc/splash_execution_report.tpl
|
70
|
+
👍 Creating/Checking pid file path : /var/run/splash
|
71
|
+
👍 Creating/Checking trace file path : /var/run/spla
|
72
|
+
|
73
|
+
*NOTE : you can just type 'splash' withou any arguments, for the first setup because, Splash come with an automatic recovery mode, when configuration file is missing, run at the very beginnning of his the execution*
|
72
74
|
|
73
75
|
*WARNING : if you have already configured Splash, running this command without --preserve flag, RESET the Splash Configuration.*
|
74
76
|
|
@@ -121,7 +123,7 @@ For file/folders if problems is detected, it could be such as :
|
|
121
123
|
run :
|
122
124
|
|
123
125
|
$ splash config version
|
124
|
-
Splash version : 0.0
|
126
|
+
Splash version : 0.6.0, Author : Romain GEORGES <gems@ultragreen.net>
|
125
127
|
Ultragreen (c) 2020 BSD-2-Clause
|
126
128
|
|
127
129
|
|
@@ -652,74 +654,70 @@ TODO
|
|
652
654
|
|
653
655
|
defined in the lib/splash/constants.rb
|
654
656
|
|
655
|
-
```ruby
|
656
657
|
|
657
|
-
|
658
|
-
|
658
|
+
|
659
|
+
# the only one non-overridable by the configuration
|
660
|
+
CONFIG_FILE = "/etc/splash.yml"
|
659
661
|
|
660
662
|
|
661
|
-
TRACE_PATH="/var/run/splash"
|
663
|
+
TRACE_PATH="/var/run/splash"
|
662
664
|
|
663
|
-
DAEMON_LOGMON_SCHEDULING={ :every => '20s'}
|
664
|
-
DAEMON_PROCESS_NAME="Splash : daemon."
|
665
|
-
DAEMON_PID_PATH="/var/run"
|
666
|
-
DAEMON_PID_FILE="splash.pid"
|
667
|
-
DAEMON_STDOUT_TRACE="stdout.txt"
|
668
|
-
DAEMON_STDERR_TRACE="stderr.txt"
|
665
|
+
DAEMON_LOGMON_SCHEDULING={ :every => '20s'}
|
666
|
+
DAEMON_PROCESS_NAME="Splash : daemon."
|
667
|
+
DAEMON_PID_PATH="/var/run"
|
668
|
+
DAEMON_PID_FILE="splash.pid"
|
669
|
+
DAEMON_STDOUT_TRACE="stdout.txt"
|
670
|
+
DAEMON_STDERR_TRACE="stderr.txt"
|
669
671
|
|
670
|
-
AUTHOR="Romain GEORGES"
|
671
|
-
EMAIL = "gems@ultragreen.net"
|
672
|
-
COPYRIGHT="Ultragreen (c) 2020"
|
673
|
-
LICENSE="BSD-2-Clause"
|
672
|
+
AUTHOR="Romain GEORGES"
|
673
|
+
EMAIL = "gems@ultragreen.net"
|
674
|
+
COPYRIGHT="Ultragreen (c) 2020"
|
675
|
+
LICENSE="BSD-2-Clause"
|
674
676
|
|
675
|
-
PROMETHEUS_PUSHGATEWAY_HOST = "localhost"
|
676
|
-
PROMETHEUS_PUSHGATEWAY_PORT = "9091"
|
677
|
+
PROMETHEUS_PUSHGATEWAY_HOST = "localhost"
|
678
|
+
PROMETHEUS_PUSHGATEWAY_PORT = "9091"
|
677
679
|
|
678
|
-
EXECUTION_TEMPLATE="/etc/splash_execution_report.tpl"
|
679
|
-
EXECUTION_TEMPLATE_TOKENS_LIST = [:end_date,:start_date,:cmd_name,:cmd_line,:stdout,:stderr,:desc,:status,:exec_time]
|
680
|
+
EXECUTION_TEMPLATE="/etc/splash_execution_report.tpl"
|
681
|
+
EXECUTION_TEMPLATE_TOKENS_LIST = [:end_date,:start_date,:cmd_name,:cmd_line,:stdout,:stderr,:desc,:status,:exec_time]
|
680
682
|
|
681
|
-
BACKENDS_STRUCT = { :list => [:file,:redis],
|
683
|
+
BACKENDS_STRUCT = { :list => [:file,:redis],
|
682
684
|
:stores => { :execution_trace => { :type => :file, :path => "/var/run/splash" }}}
|
683
|
-
TRANSPORTS_STRUCT = { :list => [:rabbitmq],
|
685
|
+
TRANSPORTS_STRUCT = { :list => [:rabbitmq],
|
684
686
|
:active => :rabbitmq,
|
685
687
|
:rabbitmq => { :url => 'amqp://localhost/'} }
|
686
688
|
|
687
|
-
```
|
688
|
-
|
689
689
|
|
690
690
|
#### Splash CLI return code significations
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
```
|
722
|
-
}
|
691
|
+
|
692
|
+
|
693
|
+
# context execution
|
694
|
+
:not_root => {:message => "This operation need to be run as root (use sudo or rvmsudo)", :code => 10},
|
695
|
+
:options_incompatibility => {:message => "Options incompatibility", :code => 40},
|
696
|
+
:service_dependence_missing => {:message => "Splash Service dependence missing", :code => 60},
|
697
|
+
|
698
|
+
# config
|
699
|
+
:specific_config_required => {:message => "Specific configuration required", :code => 30},
|
700
|
+
:splash_setup_error => {:message => "Splash Setup terminated unsuccessfully", :code => 25},
|
701
|
+
:splash_setup_success => {:message => "Splash Setup terminated successfully", :code => 0},
|
702
|
+
:splash_sanitycheck_error => {:message => "Splash Sanitycheck terminated unsuccessfully", :code => 20},
|
703
|
+
:splash_sanitycheck_success => {:message => "Splash Sanitycheck terminated successfully", :code => 0},
|
704
|
+
:configuration_error => {:message => "Splash Configuration Error", :code => 50},
|
705
|
+
|
706
|
+
|
707
|
+
# global
|
708
|
+
:quiet_exit => {:code => 0},
|
709
|
+
|
710
|
+
# events
|
711
|
+
:interrupt => {:message => "Splash user operation interrupted", :code => 33},
|
712
|
+
|
713
|
+
# request
|
714
|
+
:not_found => {:message => "Object not found", :code => 44},
|
715
|
+
:already_exist => {:message => "Object already exist", :code => 48},
|
716
|
+
|
717
|
+
# daemon
|
718
|
+
:status_ok => {:message => "Status OK", :code => 0},
|
719
|
+
:status_ko => {:message => "Status KO", :code => 31}
|
720
|
+
|
723
721
|
|
724
722
|
### In the Futur ?
|
725
723
|
|
data/bin/splash
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
+
# major include
|
4
5
|
require 'splash/dependencies'
|
5
6
|
require 'splash/cli'
|
6
7
|
|
@@ -13,6 +14,7 @@ include Splash::Exiter
|
|
13
14
|
include Splash::Loggers
|
14
15
|
include Splash::Config
|
15
16
|
|
17
|
+
# auto setup
|
16
18
|
unless verify_file(name: CONFIG_FILE, mode: "644", owner: user_root, group: group_root).empty? then
|
17
19
|
puts 'Splash need reconfiguration : Auto setup launch'
|
18
20
|
|
@@ -26,4 +28,5 @@ unless verify_file(name: CONFIG_FILE, mode: "644", owner: user_root, group: grou
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
31
|
+
# running Thor
|
29
32
|
CLI.start(ARGV)
|
data/config/splash.yml
CHANGED
@@ -50,6 +50,17 @@
|
|
50
50
|
:pushgateway:
|
51
51
|
:host: "localhost"
|
52
52
|
:port: 9091
|
53
|
+
:path: ''
|
54
|
+
:url: "http://localhost:9090/"
|
55
|
+
:webadmin:
|
56
|
+
:port: 9234
|
57
|
+
:ip: 127.0.0.1
|
58
|
+
:proxy: false
|
59
|
+
:process_name: "Splash : WebAdmin."
|
60
|
+
:files:
|
61
|
+
:stdout_trace: stdout_webadmin.txt
|
62
|
+
:stderr_trace: stderr_webadmin.txt
|
63
|
+
:pid_file: splash_webadmin.pid
|
53
64
|
|
54
65
|
|
55
66
|
### configuration of commands and scheduling
|
@@ -106,9 +117,11 @@
|
|
106
117
|
|
107
118
|
### configuration of monitored logs
|
108
119
|
:logs:
|
109
|
-
- :
|
120
|
+
- :label: :log_app_1
|
121
|
+
:log: /tmp/test
|
110
122
|
:pattern: ERROR
|
111
|
-
- :
|
123
|
+
- :label: :log_app_2
|
124
|
+
:log: /tmp/test2
|
112
125
|
:pattern: ERROR
|
113
126
|
|
114
127
|
|
data/lib/splash/backends.rb
CHANGED
@@ -1,11 +1,17 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Dir[File.dirname(__FILE__) + '/backends/*.rb'].each {|file| require file }
|
3
3
|
|
4
|
+
# base Splash Module
|
4
5
|
module Splash
|
6
|
+
|
7
|
+
# generic backends module
|
5
8
|
module Backends
|
6
9
|
include Splash::Config
|
7
10
|
include Splash::Constants
|
8
11
|
|
12
|
+
# factory for backend
|
13
|
+
# @param [Symbol] store the name of the store actually in [:execution_trace]
|
14
|
+
# @return [Splash::Backends::<Type>|Hash] with type in [:redis,:file] or Exiter case :configuration_error
|
9
15
|
def get_backend(store)
|
10
16
|
backend = get_config[:backends][:stores][store][:type].to_s
|
11
17
|
aclass = "Splash::Backends::#{backend.capitalize}"
|
data/lib/splash/backends/file.rb
CHANGED
@@ -1,50 +1,86 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
3
|
+
# base Splash Module
|
2
4
|
module Splash
|
5
|
+
# generic backends module
|
3
6
|
module Backends
|
7
|
+
|
8
|
+
# File backend definition
|
4
9
|
class File
|
5
10
|
include Splash::Config
|
6
11
|
include Splash::Exiter
|
7
12
|
include Splash::Helpers
|
8
13
|
include Splash::Loggers
|
9
14
|
|
15
|
+
# Constructor
|
16
|
+
# @param [Symbol] store name in [:execution_trace] actually (see config and constants )
|
17
|
+
# @return [Splash::Backends::File] a File backend
|
10
18
|
def initialize(store)
|
11
19
|
@config = get_config[:backends][:stores][store]
|
12
20
|
@path = @config[:path]
|
13
21
|
ensure_backend
|
14
22
|
end
|
15
23
|
|
24
|
+
# return the list of find records in backend for a specific pattern
|
25
|
+
# @param [String] pattern shell regexp
|
26
|
+
# @return [Array] list of record
|
16
27
|
def list(pattern='*')
|
17
28
|
pattern = suffix_trace(pattern)
|
18
29
|
return Dir.glob("#{@path}/#{pattern}").map{|item| ::File.basename(item,".trace") }
|
19
30
|
end
|
20
31
|
|
32
|
+
|
33
|
+
# return value of queried record
|
34
|
+
# @param [Hash] options
|
35
|
+
# @option options [Symbol] :key the name of the record
|
36
|
+
# @return [String] content value of record
|
21
37
|
def get(options)
|
22
38
|
return ::File.readlines("#{@path}/#{suffix_trace(options[:key])}").join
|
23
39
|
end
|
24
40
|
|
41
|
+
# defined and store value for specified key
|
42
|
+
# @param [Hash] options
|
43
|
+
# @option options [Symbol] :key the name of the record
|
44
|
+
# @option options [Symbol] :value the content value of the record
|
45
|
+
# @return [String] content value of record
|
25
46
|
def put(options)
|
26
47
|
::File.open("#{@path}/#{suffix_trace(options[:key])}", 'w') { |file|
|
27
48
|
file.write options[:value]
|
28
49
|
}
|
29
50
|
end
|
30
51
|
|
52
|
+
# delete a specific record
|
53
|
+
# @param [Hash] options
|
54
|
+
# @option options [Symbol] :key the name of the record
|
55
|
+
# @return [Boolean] status of the operation
|
31
56
|
def del(options)
|
32
57
|
::File.unlink("#{@path}/#{suffix_trace(options[:key])}") if File.exist?("#{@path}/#{suffix_trace(options[:key])}")
|
33
58
|
end
|
34
59
|
|
60
|
+
# verifiy a specific record existance
|
61
|
+
# @param [Hash] options
|
62
|
+
# @option options [Symbol] :key the name of the record
|
63
|
+
# @return [Boolean] presence of the record
|
35
64
|
def exist?(options)
|
36
65
|
return ::File.exist?("#{@path}/#{suffix_trace(options[:key])}")
|
37
66
|
end
|
38
67
|
|
68
|
+
# flush all records in backend
|
39
69
|
def flush
|
40
70
|
Dir.glob("#{@path}/*.trace").each { |file| ::File.delete(file)}
|
41
71
|
end
|
42
72
|
|
43
73
|
private
|
74
|
+
|
75
|
+
# File backend specific method for suffixing record name with .trace for filename
|
76
|
+
# @param [String] astring
|
77
|
+
# @return [String] suffixed string
|
44
78
|
def suffix_trace(astring)
|
45
79
|
return "#{astring}.trace"
|
46
80
|
end
|
47
81
|
|
82
|
+
# File backend specific method to test backend, correcting if requiered, spool path checking
|
83
|
+
# @return [True|Hash] Exiter case :configuration_error if failing to correct backend
|
48
84
|
def ensure_backend
|
49
85
|
unless verify_folder(name: @config[:path], mode: "644", owner: get_config.user_root, group: get_config.group_root).empty? then
|
50
86
|
get_logger.warn "File Backend folder : #{@config[:path]} is missing"
|
@@ -1,8 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
3
|
+
# base Splash Module
|
2
4
|
module Splash
|
5
|
+
|
6
|
+
# generic backends module
|
3
7
|
module Backends
|
8
|
+
|
9
|
+
# Redis backend definition
|
4
10
|
class Redis
|
5
11
|
include Splash::Config
|
12
|
+
|
13
|
+
# Constructor
|
14
|
+
# @param [Symbol] store name in [:execution_trace] actually (see config and constants )
|
15
|
+
# @return [Splash::Backends::Redis] a Redis backend
|
6
16
|
def initialize(store)
|
7
17
|
@hostname = Socket.gethostname
|
8
18
|
@config = get_config[:backends][:stores][store]
|
@@ -13,45 +23,78 @@ module Splash
|
|
13
23
|
@store.auth(@config[:auth]) if @config[:auth]
|
14
24
|
end
|
15
25
|
|
26
|
+
# return the list of find records in backend for a specific pattern
|
27
|
+
# @param [String] hostname optionnal (default : local hostname)
|
28
|
+
# @param [String] pattern shell regexp
|
29
|
+
# @return [Array] list of record (for all hostname if hostname is specified)
|
16
30
|
def list(pattern='*', hostname = @hostname)
|
17
31
|
return @store.keys("#{hostname}##{pattern}").map{|item| item = remove_hostname(item)}
|
18
32
|
end
|
19
33
|
|
34
|
+
# return the list of find records in backend for a specific pattern, without hostname Checking
|
35
|
+
# Redis Backend specific method
|
36
|
+
# @param [String] pattern shell regexp
|
37
|
+
# @return [Array] list of record (for all hostname if hostname is specified)
|
20
38
|
def listall(pattern='*')
|
21
39
|
return @store.keys(pattern)
|
22
40
|
end
|
23
41
|
|
42
|
+
# return value of queried record
|
43
|
+
# @param [Hash] options
|
44
|
+
# @option options [Symbol] :key the name of the record
|
45
|
+
# @return [String] content value of record
|
24
46
|
def get(options)
|
25
47
|
hostname = (options[:hostname])? options[:hostname] : @hostname
|
26
48
|
return @store.get(prefix_hostname(options[:key],hostname))
|
27
49
|
end
|
28
50
|
|
51
|
+
# defined and store value for specified key
|
52
|
+
# @param [Hash] options
|
53
|
+
# @option options [Symbol] :key the name of the record
|
54
|
+
# @option options [Symbol] :value the content value of the record
|
55
|
+
# @return [String] content value of record
|
29
56
|
def put(options)
|
30
57
|
hostname = (options[:hostname])? options[:hostname] : @hostname
|
31
58
|
@store.set prefix_hostname(options[:key],hostname), options[:value]
|
32
59
|
end
|
33
60
|
|
61
|
+
# delete a specific record
|
62
|
+
# @param [Hash] options
|
63
|
+
# @option options [Symbol] :key the name of the record
|
64
|
+
# @return [Boolean] status of the operation
|
34
65
|
def del(options)
|
35
66
|
hostname = (options[:hostname])? options[:hostname] : @hostname
|
36
67
|
@store.del prefix_hostname(options[:key],hostname)
|
37
68
|
end
|
38
69
|
|
70
|
+
# flush all records in backend
|
39
71
|
def flush
|
40
72
|
#`#{@redis_cli_cmd} -n #{@config[:base]} flushdb`
|
41
73
|
@store.flushdb
|
42
74
|
end
|
43
75
|
|
76
|
+
# verifiy a specific record existance
|
77
|
+
# @param [Hash] options
|
78
|
+
# @option options [Symbol] :key the name of the record
|
79
|
+
# @return [Boolean] presence of the record
|
44
80
|
def exist?(options)
|
45
81
|
hostname = (options[:hostname])? options[:hostname] : @hostname
|
46
82
|
return ( not @store.get(prefix_hostname(options[:key],hostname)).nil?)
|
47
83
|
end
|
48
84
|
|
49
85
|
private
|
86
|
+
|
87
|
+
# Redis backend specific method for prefix record name with hostname
|
88
|
+
# @param [String] key
|
89
|
+
# @param [String] hostname
|
90
|
+
# @return [String] prefixed string
|
50
91
|
def prefix_hostname(key,hostname)
|
51
92
|
return "#{hostname}##{key}"
|
52
93
|
end
|
53
94
|
|
54
|
-
|
95
|
+
# Redis backend specific method for removing hostname of record
|
96
|
+
# @param [String] astring
|
97
|
+
# @return [String] cleaned string
|
55
98
|
def remove_hostname(astring)
|
56
99
|
result = astring.split("#")
|
57
100
|
result.shift
|
data/lib/splash/cli.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Dir[File.dirname(__FILE__) + '/cli/*.rb'].each {|file| require file }
|
3
3
|
|
4
|
+
# The CLI Command structure for Thor
|
4
5
|
class CLI < Thor
|
6
|
+
|
7
|
+
# callback for managing ARGV errors
|
5
8
|
def self.exit_on_failure?
|
6
9
|
true
|
7
10
|
end
|
8
11
|
|
9
|
-
|
12
|
+
# Constructor override to manage debug, colors and emoji options for logger
|
10
13
|
def initialize(*args)
|
11
14
|
super
|
12
15
|
log = get_logger
|
@@ -30,13 +33,14 @@ class CLI < Thor
|
|
30
33
|
subcommand "logs", Logs
|
31
34
|
desc "processes SUBCOMMAND ...ARGS", "Managing processes supervision"
|
32
35
|
subcommand "processes", Processes
|
33
|
-
desc "daemon SUBCOMMAND ...ARGS", "Splash daemon
|
36
|
+
desc "daemon SUBCOMMAND ...ARGS", "Splash daemon controller"
|
34
37
|
subcommand "daemon", CLIController
|
35
38
|
desc "config SUBCOMMAND ...ARGS", "Config tools for Splash"
|
36
39
|
subcommand "config", Config
|
37
40
|
desc "documentation SUBCOMMAND ...ARGS", "Documentation for Splash"
|
38
41
|
subcommand "documentation", Documentation
|
39
|
-
|
42
|
+
desc "webadmin SUBCOMMAND ...ARGS", "Splash Webadmin daemon controller"
|
43
|
+
subcommand "webadmin", WebAdmin
|
40
44
|
|
41
45
|
|
42
46
|
end
|