servitude 0.5.0 → 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 +6 -1
- data/examples/1_simple_server +11 -11
- data/examples/2_echo_server +11 -11
- data/examples/3_echo_server_with_cli_and_daemon +15 -14
- data/examples/4_echo_server_with_cli_daemon_and_file_config +15 -14
- data/examples/5_echo_server_with_cli_daemon_and_env_config +15 -14
- data/lib/servitude.rb +20 -1
- data/lib/servitude/base.rb +19 -2
- data/lib/servitude/cli/service.rb +8 -8
- data/lib/servitude/config_helper.rb +1 -1
- data/lib/servitude/daemon.rb +8 -8
- data/lib/servitude/logging.rb +1 -1
- data/lib/servitude/server.rb +1 -1
- data/lib/servitude/server_logging.rb +9 -15
- data/lib/servitude/util.rb +6 -4
- data/lib/servitude/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed81f9149d3c5085e1e691ad830d40c337f37fe
|
4
|
+
data.tar.gz: 38bdad215162d770e65fd0d863f87bc63e440690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0844e314602b73d341053e701279d3130686eaa28ede6b5312c42f32e7ab3e746f50db101a272b7b775802d36f9e549c05a41fc2845db399ca37ff677e1a2733
|
7
|
+
data.tar.gz: a2f0dbabf95bfb36f833726f04680c496d19a20d8b0f4c3b1114b92034467b2e3fa90ce7091c7abd845b3962baade12659462ecf6d745f78a3c7a8f16f369bc1
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ If you do not call ::boot, an error is raised before your server can be started.
|
|
73
73
|
default_config_path: "/etc/awesome/awesome-server.conf",
|
74
74
|
default_log_path: "/var/log/awesome/awesome-server.log",
|
75
75
|
default_pid_path: "/var/run/awesome/awesome-server.pid",
|
76
|
-
default_thread_count: 1
|
76
|
+
default_thread_count: 1
|
77
77
|
end
|
78
78
|
|
79
79
|
### Servitude::Cli
|
@@ -352,3 +352,8 @@ The #with_supervision block implements error handling/retry logic required to co
|
|
352
352
|
The #some_event_generated_block method call in the code block above represents some even that happend that needs to be processed. All servers sleep until an event
|
353
353
|
happens and then do some work, respond and then go back to sleep. Some good examples are receiving packets form a TCP/UDP socket or receiving a message from a
|
354
354
|
message queue.
|
355
|
+
|
356
|
+
|
357
|
+
## Contributors
|
358
|
+
|
359
|
+
* Nils Jonsson [njonsson](https://github.com/njonsson)
|
data/examples/1_simple_server
CHANGED
@@ -21,17 +21,6 @@ module SimpleServer
|
|
21
21
|
VERSION = '1.0.0'
|
22
22
|
|
23
23
|
PROJECT_ROOT = File.expand_path( '../..', __FILE__ )
|
24
|
-
|
25
|
-
boot host_namespace: SimpleServer,
|
26
|
-
app_id: 'simple-server',
|
27
|
-
app_name: 'Simple Server',
|
28
|
-
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
29
|
-
author: 'LFE',
|
30
|
-
use_config: false,
|
31
|
-
default_config_path: nil,
|
32
|
-
default_log_path: nil,
|
33
|
-
default_pid_path: nil,
|
34
|
-
default_thread_count: nil
|
35
24
|
|
36
25
|
class Server
|
37
26
|
|
@@ -46,6 +35,17 @@ module SimpleServer
|
|
46
35
|
end
|
47
36
|
|
48
37
|
end
|
38
|
+
|
39
|
+
boot host_namespace: SimpleServer,
|
40
|
+
app_id: 'simple-server',
|
41
|
+
app_name: 'Simple Server',
|
42
|
+
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
43
|
+
author: 'LFE',
|
44
|
+
use_config: false,
|
45
|
+
default_config_path: nil,
|
46
|
+
default_log_path: nil,
|
47
|
+
default_pid_path: nil,
|
48
|
+
default_thread_count: nil
|
49
49
|
end
|
50
50
|
|
51
51
|
SimpleServer::Server.new.start
|
data/examples/2_echo_server
CHANGED
@@ -27,17 +27,6 @@ module EchoServer
|
|
27
27
|
VERSION = '1.0.0'
|
28
28
|
|
29
29
|
PROJECT_ROOT = File.expand_path( '../..', __FILE__ )
|
30
|
-
|
31
|
-
boot host_namespace: EchoServer,
|
32
|
-
app_id: 'echo-server',
|
33
|
-
app_name: 'Echo Server',
|
34
|
-
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
35
|
-
author: 'LFE',
|
36
|
-
use_config: false,
|
37
|
-
default_config_path: nil,
|
38
|
-
default_log_path: nil,
|
39
|
-
default_pid_path: nil,
|
40
|
-
default_thread_count: nil
|
41
30
|
|
42
31
|
class Server
|
43
32
|
|
@@ -68,6 +57,17 @@ module EchoServer
|
|
68
57
|
attr_reader :tcp_server
|
69
58
|
|
70
59
|
end
|
60
|
+
|
61
|
+
boot host_namespace: EchoServer,
|
62
|
+
app_id: 'echo-server',
|
63
|
+
app_name: 'Echo Server',
|
64
|
+
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
65
|
+
author: 'LFE',
|
66
|
+
use_config: false,
|
67
|
+
default_config_path: nil,
|
68
|
+
default_log_path: nil,
|
69
|
+
default_pid_path: nil,
|
70
|
+
default_thread_count: nil
|
71
71
|
end
|
72
72
|
|
73
73
|
EchoServer::Server.new.start
|
@@ -38,20 +38,6 @@ module EchoServer
|
|
38
38
|
VERSION = '1.0.0'
|
39
39
|
|
40
40
|
PROJECT_ROOT = File.expand_path( '../..', __FILE__ )
|
41
|
-
|
42
|
-
boot host_namespace: EchoServer,
|
43
|
-
app_id: 'echo-server-with-cli',
|
44
|
-
app_name: 'Echo Server With CLI',
|
45
|
-
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
46
|
-
author: 'LFE',
|
47
|
-
use_config: false,
|
48
|
-
default_config_path: "#{PROJECT_ROOT}}/config/#{APP_FOLDER}.conf",
|
49
|
-
default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
|
50
|
-
default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
|
51
|
-
default_thread_count: nil
|
52
|
-
|
53
|
-
class Cli < Servitude::Cli::Service
|
54
|
-
end
|
55
41
|
|
56
42
|
class Server
|
57
43
|
|
@@ -88,6 +74,21 @@ module EchoServer
|
|
88
74
|
attr_reader :tcp_server
|
89
75
|
|
90
76
|
end
|
77
|
+
|
78
|
+
boot host_namespace: EchoServer,
|
79
|
+
app_id: 'echo-server-with-cli',
|
80
|
+
app_name: 'Echo Server With CLI',
|
81
|
+
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
82
|
+
author: 'LFE',
|
83
|
+
use_config: false,
|
84
|
+
default_config_path: "#{PROJECT_ROOT}}/config/#{APP_FOLDER}.conf",
|
85
|
+
default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
|
86
|
+
default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
|
87
|
+
default_thread_count: nil
|
88
|
+
|
89
|
+
class Cli < Servitude::Cli::Service
|
90
|
+
end
|
91
|
+
|
91
92
|
end
|
92
93
|
|
93
94
|
EchoServer::Cli.start
|
@@ -38,20 +38,6 @@ module EchoServer
|
|
38
38
|
VERSION = '1.0.0'
|
39
39
|
|
40
40
|
PROJECT_ROOT = File.expand_path( '../..', __FILE__ )
|
41
|
-
|
42
|
-
boot host_namespace: EchoServer,
|
43
|
-
app_id: 'echo-server-with-cli-and-file-config',
|
44
|
-
app_name: 'Echo Server With CLI And File Config',
|
45
|
-
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
46
|
-
author: 'LFE',
|
47
|
-
use_config: true,
|
48
|
-
default_config_path: "#{PROJECT_ROOT}/config/4.conf",
|
49
|
-
default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
|
50
|
-
default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
|
51
|
-
default_thread_count: nil
|
52
|
-
|
53
|
-
class Cli < Servitude::Cli::Service
|
54
|
-
end
|
55
41
|
|
56
42
|
class Server
|
57
43
|
|
@@ -88,6 +74,21 @@ module EchoServer
|
|
88
74
|
attr_reader :tcp_server
|
89
75
|
|
90
76
|
end
|
77
|
+
|
78
|
+
boot host_namespace: EchoServer,
|
79
|
+
app_id: 'echo-server-with-cli-and-file-config',
|
80
|
+
app_name: 'Echo Server With CLI And File Config',
|
81
|
+
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
82
|
+
author: 'LFE',
|
83
|
+
use_config: true,
|
84
|
+
default_config_path: "#{PROJECT_ROOT}/config/4.conf",
|
85
|
+
default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
|
86
|
+
default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
|
87
|
+
default_thread_count: nil
|
88
|
+
|
89
|
+
class Cli < Servitude::Cli::Service
|
90
|
+
end
|
91
|
+
|
91
92
|
end
|
92
93
|
|
93
94
|
EchoServer::Cli.start
|
@@ -46,20 +46,6 @@ module EchoServer
|
|
46
46
|
VERSION = '1.0.0'
|
47
47
|
|
48
48
|
PROJECT_ROOT = File.expand_path( '../..', __FILE__ )
|
49
|
-
|
50
|
-
boot host_namespace: EchoServer,
|
51
|
-
app_id: 'echo-server-with-cli-and-env-config',
|
52
|
-
app_name: 'Echo Server With CLI And Env Config',
|
53
|
-
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
54
|
-
author: 'LFE',
|
55
|
-
use_config: true,
|
56
|
-
default_config_path: "#{PROJECT_ROOT}/config/5.conf",
|
57
|
-
default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
|
58
|
-
default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
|
59
|
-
default_thread_count: nil
|
60
|
-
|
61
|
-
class Cli < Servitude::Cli::Service
|
62
|
-
end
|
63
49
|
|
64
50
|
class Server
|
65
51
|
|
@@ -104,6 +90,21 @@ module EchoServer
|
|
104
90
|
attr_reader :tcp_server
|
105
91
|
|
106
92
|
end
|
93
|
+
|
94
|
+
boot host_namespace: EchoServer,
|
95
|
+
app_id: 'echo-server-with-cli-and-env-config',
|
96
|
+
app_name: 'Echo Server With CLI And Env Config',
|
97
|
+
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
98
|
+
author: 'LFE',
|
99
|
+
use_config: true,
|
100
|
+
default_config_path: "#{PROJECT_ROOT}/config/5.conf",
|
101
|
+
default_log_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.log",
|
102
|
+
default_pid_path: "#{PROJECT_ROOT}/tmp/#{APP_FOLDER}.pid",
|
103
|
+
default_thread_count: nil
|
104
|
+
|
105
|
+
class Cli < Servitude::Cli::Service
|
106
|
+
end
|
107
|
+
|
107
108
|
end
|
108
109
|
|
109
110
|
EchoServer::Cli.start
|
data/lib/servitude.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'servitude/version'
|
2
2
|
require 'rainbow'
|
3
|
+
require 'yell'
|
3
4
|
|
4
5
|
module Servitude
|
5
6
|
|
@@ -22,7 +23,25 @@ module Servitude
|
|
22
23
|
TERM = "TERM"
|
23
24
|
|
24
25
|
class << self
|
25
|
-
attr_accessor :boot_called
|
26
|
+
attr_accessor :boot_called, :configuration, :logger
|
27
|
+
|
28
|
+
def initialize_loggers( log_level: nil, filename: nil )
|
29
|
+
raise ArgumentError, 'log_level keyword is required' unless log_level
|
30
|
+
|
31
|
+
logger.adapter.close if logger && logger.adapter
|
32
|
+
|
33
|
+
self.logger = Yell.new do |l|
|
34
|
+
l.level = log_level
|
35
|
+
if filename
|
36
|
+
l.adapter :file, filename, :level => [:debug, :info, :warn]
|
37
|
+
else
|
38
|
+
l.adapter $stdout, :level => [:debug, :info, :warn]
|
39
|
+
l.adapter $stderr, :level => [:error, :fatal]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
26
43
|
end
|
27
44
|
|
45
|
+
Servitude.initialize_loggers log_level: :info
|
46
|
+
|
28
47
|
end
|
data/lib/servitude/base.rb
CHANGED
@@ -27,6 +27,7 @@ module Servitude
|
|
27
27
|
default_log_path: nil,
|
28
28
|
default_pid_path: nil,
|
29
29
|
default_thread_count: nil,
|
30
|
+
server_class: ( host_namespace::Server rescue nil ),
|
30
31
|
version_copyright: nil ) # TODO: Remove when version_copyright keyword deprecation expires
|
31
32
|
unless host_namespace
|
32
33
|
raise ArgumentError, 'host_namespace keyword is required'
|
@@ -51,6 +52,10 @@ module Servitude
|
|
51
52
|
author = company
|
52
53
|
end
|
53
54
|
|
55
|
+
unless server_class
|
56
|
+
raise ArgumentError, "server_class keyword is required because the default, #{host_namespace.name}::Server, is not defined"
|
57
|
+
end
|
58
|
+
|
54
59
|
# TODO: Remove when version_copyright keyword deprecation expires
|
55
60
|
if version_copyright
|
56
61
|
Util.deprecate "#{Base.name}.boot version_copyright: #{version_copyright.inspect}",
|
@@ -58,8 +63,7 @@ module Servitude
|
|
58
63
|
attribution = version_copyright
|
59
64
|
end
|
60
65
|
|
61
|
-
|
62
|
-
|
66
|
+
# TODO: Remove when host namespace deprecation expires
|
63
67
|
const_set :APP_ID, app_id
|
64
68
|
const_set :APP_NAME, app_name
|
65
69
|
const_set :AUTHOR, author
|
@@ -72,6 +76,19 @@ module Servitude
|
|
72
76
|
const_set :USE_CONFIG, use_config
|
73
77
|
const_set :VERSION_COPYRIGHT, attribution # TODO: Remove when version_copyright keyword deprecation expires
|
74
78
|
|
79
|
+
Servitude.const_set :APP_ID, app_id
|
80
|
+
Servitude.const_set :APP_NAME, app_name
|
81
|
+
Servitude.const_set :AUTHOR, author
|
82
|
+
Servitude.const_set :COMPANY, author # TODO: Remove when company keyword deprecation expires
|
83
|
+
Servitude.const_set :ATTRIBUTION, attribution
|
84
|
+
Servitude.const_set :DEFAULT_CONFIG_PATH, default_config_path
|
85
|
+
Servitude.const_set :DEFAULT_LOG_PATH, default_log_path
|
86
|
+
Servitude.const_set :DEFAULT_PID_PATH, default_pid_path
|
87
|
+
Servitude.const_set :DEFAULT_THREAD_COUNT, default_thread_count
|
88
|
+
Servitude.const_set :SERVER_CLASS, server_class
|
89
|
+
Servitude.const_set :USE_CONFIG, use_config
|
90
|
+
Servitude.const_set :VERSION_COPYRIGHT, attribution # TODO: Remove when version_copyright keyword deprecation expires
|
91
|
+
|
75
92
|
Servitude::boot_called = true
|
76
93
|
end
|
77
94
|
|
@@ -7,15 +7,15 @@ module Servitude
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.pid_option
|
10
|
-
method_option :pid, desc: "The path for the PID file", type: :string, default: Servitude::
|
10
|
+
method_option :pid, desc: "The path for the PID file", type: :string, default: Servitude::DEFAULT_PID_PATH
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.common_start_options
|
14
|
-
method_option :config, type: :string, aliases: '-c', desc: "The path for the config file", default: Servitude::
|
14
|
+
method_option :config, type: :string, aliases: '-c', desc: "The path for the config file", default: Servitude::DEFAULT_CONFIG_PATH
|
15
15
|
environment_option
|
16
16
|
method_option :log_level, desc: "The log level", type: :string, aliases: '-o', default: 'info'
|
17
|
-
method_option :log, desc: "The path for the log file", type: :string, aliases: '-l', default: Servitude::
|
18
|
-
method_option :threads, desc: "The number of threads", type: :numeric, aliases: '-t', default: Servitude::
|
17
|
+
method_option :log, desc: "The path for the log file", type: :string, aliases: '-l', default: Servitude::DEFAULT_LOG_PATH
|
18
|
+
method_option :threads, desc: "The number of threads", type: :numeric, aliases: '-t', default: Servitude::DEFAULT_THREAD_COUNT
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "restart", "Stop and start the server"
|
@@ -41,12 +41,12 @@ module Servitude
|
|
41
41
|
no_commands do
|
42
42
|
|
43
43
|
def start_interactive
|
44
|
-
server = Servitude::
|
44
|
+
server = Servitude::SERVER_CLASS.new( options.merge( use_config: Servitude::USE_CONFIG, log: 'STDOUT' ))
|
45
45
|
server.start
|
46
46
|
end
|
47
47
|
|
48
48
|
def start_daemon
|
49
|
-
server = Servitude::Daemon.new( options.merge( use_config: Servitude::
|
49
|
+
server = Servitude::Daemon.new( options.merge( use_config: Servitude::USE_CONFIG ))
|
50
50
|
server.start
|
51
51
|
end
|
52
52
|
|
@@ -55,13 +55,13 @@ module Servitude
|
|
55
55
|
desc "status", "Check the status of the server daemon"
|
56
56
|
pid_option
|
57
57
|
def status
|
58
|
-
Servitude::Daemon.new( options.merge( use_config: Servitude::
|
58
|
+
Servitude::Daemon.new( options.merge( use_config: Servitude::USE_CONFIG )).status
|
59
59
|
end
|
60
60
|
|
61
61
|
desc "stop", "Stop the server daemon"
|
62
62
|
pid_option
|
63
63
|
def stop
|
64
|
-
server = Servitude::Daemon.new( options.merge( use_config: Servitude::
|
64
|
+
server = Servitude::Daemon.new( options.merge( use_config: Servitude::USE_CONFIG ))
|
65
65
|
server.stop
|
66
66
|
end
|
67
67
|
|
data/lib/servitude/daemon.rb
CHANGED
@@ -14,7 +14,7 @@ module Servitude
|
|
14
14
|
|
15
15
|
def initialize( options )
|
16
16
|
@options = options
|
17
|
-
@name = options[:name] || Servitude::
|
17
|
+
@name = options[:name] || Servitude::APP_NAME
|
18
18
|
@pid_path = options[:pid] || '.'
|
19
19
|
@pid = get_pid
|
20
20
|
@timeout = options[:timeout] || 10
|
@@ -37,7 +37,7 @@ module Servitude
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def run
|
40
|
-
Servitude::
|
40
|
+
Servitude::SERVER_CLASS.new( options ).start
|
41
41
|
end
|
42
42
|
|
43
43
|
def stop
|
@@ -46,7 +46,7 @@ module Servitude
|
|
46
46
|
remove_pid
|
47
47
|
when :failed_to_stop
|
48
48
|
when :does_not_exist
|
49
|
-
puts "#{Servitude::
|
49
|
+
puts "#{Servitude::APP_NAME} process is not running"
|
50
50
|
prompt_and_remove_pid_file if pid_file_exists?
|
51
51
|
else
|
52
52
|
raise 'Unknown return code from #kill_process'
|
@@ -55,9 +55,9 @@ module Servitude
|
|
55
55
|
|
56
56
|
def status
|
57
57
|
if process_exists?
|
58
|
-
puts "#{Servitude::
|
58
|
+
puts "#{Servitude::APP_NAME} process running with PID: #{pid}"
|
59
59
|
else
|
60
|
-
puts "#{Servitude::
|
60
|
+
puts "#{Servitude::APP_NAME} process does not exist"
|
61
61
|
prompt_and_remove_pid_file if pid_file_exists?
|
62
62
|
end
|
63
63
|
end
|
@@ -110,7 +110,7 @@ module Servitude
|
|
110
110
|
def kill_process
|
111
111
|
return :does_not_exist unless process_exists?
|
112
112
|
|
113
|
-
$stdout.write "Attempting to stop #{Servitude::
|
113
|
+
$stdout.write "Attempting to stop #{Servitude::APP_NAME} process #{pid}..."
|
114
114
|
Process.kill INT, pid
|
115
115
|
|
116
116
|
iteration_num = 0
|
@@ -121,10 +121,10 @@ module Servitude
|
|
121
121
|
end
|
122
122
|
|
123
123
|
if process_exists?
|
124
|
-
$stderr.puts "\nFailed to stop #{Servitude::
|
124
|
+
$stderr.puts "\nFailed to stop #{Servitude::APP_NAME} process #{pid}"
|
125
125
|
return :failed_to_stop
|
126
126
|
else
|
127
|
-
$stdout.puts "\nSuccessfuly stopped #{Servitude::
|
127
|
+
$stdout.puts "\nSuccessfuly stopped #{Servitude::APP_NAME} process #{pid}"
|
128
128
|
end
|
129
129
|
|
130
130
|
return :success
|
data/lib/servitude/logging.rb
CHANGED
data/lib/servitude/server.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'yell'
|
2
|
-
|
3
1
|
# Provides logging services for the base server.
|
4
2
|
#
|
5
3
|
module Servitude
|
@@ -8,16 +6,12 @@ module Servitude
|
|
8
6
|
protected
|
9
7
|
|
10
8
|
def initialize_loggers
|
11
|
-
Servitude
|
12
|
-
l.level = log_level
|
13
|
-
l.adapter $stdout, :level => [:debug, :info, :warn]
|
14
|
-
l.adapter $stderr, :level => [:error, :fatal]
|
15
|
-
end
|
9
|
+
Servitude.initialize_loggers log_level: log_level
|
16
10
|
end
|
17
11
|
|
18
12
|
def log_startup
|
19
13
|
start_banner.each do |line|
|
20
|
-
Servitude
|
14
|
+
Servitude.logger.info line
|
21
15
|
end
|
22
16
|
end
|
23
17
|
|
@@ -25,19 +19,19 @@ module Servitude
|
|
25
19
|
[
|
26
20
|
"",
|
27
21
|
"***",
|
28
|
-
"* #{Servitude::
|
22
|
+
"* #{Servitude::APP_NAME} started",
|
29
23
|
"*",
|
30
|
-
"* #{Servitude::
|
24
|
+
"* #{Servitude::VERSION_COPYRIGHT}",
|
31
25
|
"*",
|
32
|
-
(Servitude
|
33
|
-
PrettyPrint::configuration_lines( Servitude
|
34
|
-
(Servitude
|
26
|
+
(Servitude.configuration.empty? ? nil : "* Configuration"),
|
27
|
+
PrettyPrint::configuration_lines( Servitude.configuration, "* ", all_config_filters ),
|
28
|
+
(Servitude.configuration.empty? ? nil : "*"),
|
35
29
|
"***",
|
36
30
|
].flatten.reject( &:nil? )
|
37
31
|
end
|
38
32
|
|
39
33
|
def log_level
|
40
|
-
(
|
34
|
+
(Servitude.configuration.log_level.to_sym rescue :info)
|
41
35
|
end
|
42
36
|
|
43
37
|
def all_config_filters
|
@@ -59,7 +53,7 @@ module Servitude
|
|
59
53
|
end
|
60
54
|
|
61
55
|
#def config_value( key )
|
62
|
-
#value = Servitude
|
56
|
+
#value = Servitude.configuration.send( key )
|
63
57
|
|
64
58
|
#return value unless value.is_a?( Hash )
|
65
59
|
|
data/lib/servitude/util.rb
CHANGED
@@ -4,13 +4,15 @@ module Servitude
|
|
4
4
|
|
5
5
|
module Util
|
6
6
|
|
7
|
-
def self.deprecate( deprecated_usage, sanctioned_usage )
|
7
|
+
def self.deprecate( deprecated_usage, sanctioned_usage=nil )
|
8
8
|
$stderr.print Rainbow( " *** DEPRECATED " ).yellow.inverse
|
9
9
|
$stderr.print ' '
|
10
10
|
$stderr.print Rainbow( deprecated_usage ).underline
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
if sanctioned_usage
|
12
|
+
$stderr.print Rainbow(" -- use ")
|
13
|
+
$stderr.print Rainbow( sanctioned_usage ).underline
|
14
|
+
$stderr.print Rainbow(" instead")
|
15
|
+
end
|
14
16
|
$stderr.puts ''
|
15
17
|
end
|
16
18
|
|
data/lib/servitude/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servitude
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Harrelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|