servitude 1.1.0 → 1.2.0
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/README.md +8 -14
- data/examples/5_echo_server_with_cli_daemon_and_env_config +10 -5
- data/lib/servitude/cli/service.rb +14 -4
- data/lib/servitude/server.rb +0 -9
- 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: 85cc543e4150da3e50ab21b3d7da7327000136ba
|
4
|
+
data.tar.gz: 86d3362587eca8a8d697f248084ecd061bf5370a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb87b5cb3a43be43341eae3dd78414dd3183d1e5e8b2c303b9562aeb38ebb991ad8ca372abc2a0fb8deea129e09e7553fa0fc8b065feb6a64d76735f3bd40e0b
|
7
|
+
data.tar.gz: 3e92d301380d50a38960b101e0625f2f0c39998fe857fc240bc9f25c32d7a66e4fbdb6526ecc6a73b59b5dac1fd6323ed0df01e62907158ab73cdb4b998e99a3
|
data/README.md
CHANGED
@@ -102,23 +102,17 @@ For details on how to add commands to your custom or standard service CLIs see t
|
|
102
102
|
### Servitude::Configuration
|
103
103
|
|
104
104
|
All Servitude servers automatically have a configuration instantiated for them (although it may be empty). The default class for the configuration is
|
105
|
-
Servitude::Configuration. In order to define a custom configuration, define a custom
|
106
|
-
and simply override the Servitude::
|
105
|
+
Servitude::Configuration. In order to define a custom configuration, define a custom configuration class (which may inherit from Servitude::Configuration)
|
106
|
+
and simply override the Servitude::Cli::Service#configuration method in your Server class. Be sure the custom configuration calss accepts the command line
|
107
107
|
options and passes them to the super class's initializer or configuration will be completely broken.
|
108
108
|
|
109
109
|
module AwesomeServer
|
110
|
-
class
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
class Server
|
118
|
-
include Servitude::Server
|
119
|
-
|
120
|
-
def configuration_class
|
121
|
-
AwesomeServer::Configuration
|
110
|
+
class Cli < Servitude::Cli::Base
|
111
|
+
# necessary so Thor does not pick this method up as a CLI method
|
112
|
+
no_commands do
|
113
|
+
def configuration_class
|
114
|
+
AwesomeServer::Configuration
|
115
|
+
end
|
122
116
|
end
|
123
117
|
end
|
124
118
|
end
|
@@ -53,9 +53,18 @@ module EchoServer
|
|
53
53
|
attribution: "v#{VERSION} \u00A9#{Time.now.year} LFE",
|
54
54
|
author: 'LFE',
|
55
55
|
use_config: true,
|
56
|
-
default_config_path: "#{PROJECT_ROOT}/config/5.conf"
|
56
|
+
default_config_path: "#{PROJECT_ROOT}/config/5.conf"
|
57
57
|
|
58
58
|
class Cli < Servitude::Cli::Service
|
59
|
+
|
60
|
+
no_commands do
|
61
|
+
|
62
|
+
def configuration_class
|
63
|
+
Servitude::EnvironmentConfiguration
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
59
68
|
end
|
60
69
|
|
61
70
|
class Server
|
@@ -88,10 +97,6 @@ module EchoServer
|
|
88
97
|
|
89
98
|
protected
|
90
99
|
|
91
|
-
def configuration_class
|
92
|
-
Servitude::EnvironmentConfiguration
|
93
|
-
end
|
94
|
-
|
95
100
|
def config_filters
|
96
101
|
%w(threads)
|
97
102
|
end
|
@@ -41,22 +41,32 @@ module Servitude
|
|
41
41
|
no_commands do
|
42
42
|
|
43
43
|
def start_interactive
|
44
|
-
server = Servitude::server_class.new(
|
44
|
+
server = Servitude::server_class.new( configuration( options, use_config: Servitude::USE_CONFIG, log: 'STDOUT' ))
|
45
|
+
binding.pry
|
45
46
|
server.start
|
46
47
|
end
|
47
48
|
|
48
49
|
def start_daemon
|
49
|
-
server = Servitude::Daemon.new(
|
50
|
+
server = Servitude::Daemon.new( configuration( options, use_config: Servitude::USE_CONFIG ))
|
50
51
|
server.start
|
51
52
|
end
|
52
53
|
|
54
|
+
def configuration_class
|
55
|
+
Servitude::Configuration
|
56
|
+
end
|
57
|
+
|
58
|
+
def configuration( options, additional_options={} )
|
59
|
+
options = options.merge( additional_options )
|
60
|
+
Servitude.configuration = configuration_class.load( options )
|
61
|
+
end
|
62
|
+
|
53
63
|
end
|
54
64
|
|
55
65
|
desc "status", "Check the status of the server daemon"
|
56
66
|
pid_option
|
57
67
|
method_option :quiet, type: :boolean, aliases: '-q', desc: "Do not prompt to remove an old PID file", default: false
|
58
68
|
def status
|
59
|
-
result = Servitude::Daemon.new(
|
69
|
+
result = Servitude::Daemon.new( configuration( options, use_config: Servitude::USE_CONFIG )).status
|
60
70
|
at_exit { exit result }
|
61
71
|
end
|
62
72
|
|
@@ -64,7 +74,7 @@ module Servitude
|
|
64
74
|
pid_option
|
65
75
|
method_option :quiet, type: :boolean, aliases: '-q', desc: "Do not prompt to remove an old PID file", default: false
|
66
76
|
def stop
|
67
|
-
server = Servitude::Daemon.new(
|
77
|
+
server = Servitude::Daemon.new( configuration( options, use_config: Servitude::USE_CONFIG ))
|
68
78
|
server.stop
|
69
79
|
end
|
70
80
|
|
data/lib/servitude/server.rb
CHANGED
@@ -29,7 +29,6 @@ module Servitude
|
|
29
29
|
@cli_options = cli_options
|
30
30
|
|
31
31
|
run_hook :before_initialize
|
32
|
-
initialize_config
|
33
32
|
initialize_loggers
|
34
33
|
run_hook :after_initialize
|
35
34
|
end
|
@@ -52,14 +51,6 @@ module Servitude
|
|
52
51
|
raise NotImplementedError
|
53
52
|
end
|
54
53
|
|
55
|
-
def initialize_config
|
56
|
-
Servitude.configuration = configuration_class.load( cli_options )
|
57
|
-
end
|
58
|
-
|
59
|
-
def configuration_class
|
60
|
-
Servitude::Configuration
|
61
|
-
end
|
62
|
-
|
63
54
|
private
|
64
55
|
|
65
56
|
def finalize
|
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: 1.
|
4
|
+
version: 1.2.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-12-
|
11
|
+
date: 2014-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|