servitude 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/1_simple_server +11 -11
- data/examples/2_echo_server +11 -11
- data/examples/3_echo_server_with_cli_and_daemon +14 -15
- data/examples/4_echo_server_with_cli_daemon_and_file_config +14 -15
- data/examples/5_echo_server_with_cli_daemon_and_env_config +14 -15
- data/lib/servitude/base.rb +2 -2
- data/lib/servitude/cli/service.rb +1 -1
- data/lib/servitude/configuration.rb +1 -1
- data/lib/servitude/daemon.rb +4 -4
- data/lib/servitude/version.rb +1 -1
- data/lib/servitude.rb +9 -0
- 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: 4198609bfa66c7175300857b96fd908d4f17a5a4
|
4
|
+
data.tar.gz: 10f7f2510caed3307c8bf60e7a76428f0a47b82b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce42684319540490db825fea09c969bf224fc455ebd8adde6678de35c9f5158e2c1d16b648953a7c626d60abfc555c8763bb7c2c2997c701e88f75fb0a5e2904
|
7
|
+
data.tar.gz: 6d31b8d6595bd396d4df1c697d3588b25fbcde7d3ff2b9bc7be8058f401a293c2297acdb6b4d155b25d6f8feff7dc7ffcccb56840ef3727ea9ba8d4ff7c7f6ae
|
data/examples/1_simple_server
CHANGED
@@ -21,6 +21,17 @@ 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
|
24
35
|
|
25
36
|
class Server
|
26
37
|
|
@@ -35,17 +46,6 @@ module SimpleServer
|
|
35
46
|
end
|
36
47
|
|
37
48
|
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,6 +27,17 @@ 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
|
30
41
|
|
31
42
|
class Server
|
32
43
|
|
@@ -57,17 +68,6 @@ module EchoServer
|
|
57
68
|
attr_reader :tcp_server
|
58
69
|
|
59
70
|
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,6 +38,20 @@ 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
|
41
55
|
|
42
56
|
class Server
|
43
57
|
|
@@ -74,21 +88,6 @@ module EchoServer
|
|
74
88
|
attr_reader :tcp_server
|
75
89
|
|
76
90
|
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
|
-
|
92
91
|
end
|
93
92
|
|
94
93
|
EchoServer::Cli.start
|
@@ -38,6 +38,20 @@ 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
|
41
55
|
|
42
56
|
class Server
|
43
57
|
|
@@ -74,21 +88,6 @@ module EchoServer
|
|
74
88
|
attr_reader :tcp_server
|
75
89
|
|
76
90
|
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
|
-
|
92
91
|
end
|
93
92
|
|
94
93
|
EchoServer::Cli.start
|
@@ -46,6 +46,20 @@ 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
|
49
63
|
|
50
64
|
class Server
|
51
65
|
|
@@ -90,21 +104,6 @@ module EchoServer
|
|
90
104
|
attr_reader :tcp_server
|
91
105
|
|
92
106
|
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
|
-
|
108
107
|
end
|
109
108
|
|
110
109
|
EchoServer::Cli.start
|
data/lib/servitude/base.rb
CHANGED
@@ -27,7 +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
|
30
|
+
server_class: ( host_namespace::Server rescue "#{host_namespace.name}::Server" ),
|
31
31
|
version_copyright: nil ) # TODO: Remove when version_copyright keyword deprecation expires
|
32
32
|
unless host_namespace
|
33
33
|
raise ArgumentError, 'host_namespace keyword is required'
|
@@ -53,7 +53,7 @@ module Servitude
|
|
53
53
|
end
|
54
54
|
|
55
55
|
unless server_class
|
56
|
-
raise ArgumentError,
|
56
|
+
raise ArgumentError, 'server_class keyword is required'
|
57
57
|
end
|
58
58
|
|
59
59
|
# TODO: Remove when version_copyright keyword deprecation expires
|
@@ -41,7 +41,7 @@ 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
|
|
data/lib/servitude/daemon.rb
CHANGED
@@ -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
|
@@ -74,7 +74,7 @@ module Servitude
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def remove_pid
|
77
|
-
FileUtils.rm( pid_path ) if File.
|
77
|
+
FileUtils.rm( pid_path ) if File.file?( pid_path )
|
78
78
|
end
|
79
79
|
|
80
80
|
def store_pid( pid )
|
@@ -87,7 +87,7 @@ module Servitude
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def get_pid
|
90
|
-
return nil unless File.
|
90
|
+
return nil unless File.file?( pid_path )
|
91
91
|
|
92
92
|
pid = nil
|
93
93
|
|
@@ -133,7 +133,7 @@ module Servitude
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def pid_file_exists?
|
136
|
-
File.
|
136
|
+
File.file? pid_path
|
137
137
|
end
|
138
138
|
|
139
139
|
def process_exists?
|
data/lib/servitude/version.rb
CHANGED
data/lib/servitude.rb
CHANGED
@@ -40,6 +40,15 @@ module Servitude
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
def server_class
|
45
|
+
case SERVER_CLASS
|
46
|
+
when String, Symbol
|
47
|
+
eval SERVER_CLASS.to_s, binding, __FILE__, __LINE__
|
48
|
+
else
|
49
|
+
SERVER_CLASS
|
50
|
+
end
|
51
|
+
end
|
43
52
|
end
|
44
53
|
|
45
54
|
Servitude.initialize_loggers log_level: :info
|
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.7.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-10-
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|