emmy-engine 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/emmy/runner.rb +48 -3
- data/lib/emmy/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: 2ca6fbf6bf4fe55da6118207a8364f8e7c9e3e6e
|
4
|
+
data.tar.gz: 7ac4430acd303c198bb530719da1cc1731422079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd9eb63595163b681075ab2b70acedd73ceddb639cb5562373a3c9707881b33d6e127849268ac1173174fdcc4f4c01b3384dbc104fe7f2f35b4a0c41cf752c21
|
7
|
+
data.tar.gz: 26223b0c416dd7bf78522aa8ae2e4c4fb9a9549b0d99b1d2c7be2626604621ed9b05b9f362aeaa14888a8e9a27dab4386b0b22d0697da259d24c9da43a97d778
|
data/lib/emmy/runner.rb
CHANGED
@@ -60,7 +60,7 @@ module Emmy
|
|
60
60
|
"Default: #{config.url.host}") { |address| config.url.host = address }
|
61
61
|
opts.on("-b", "--backend [name]", "Backend name",
|
62
62
|
"Default: backend") { |name| config.backend = name }
|
63
|
-
opts.on("-d", "--daemonize", "Runs server in the background") {
|
63
|
+
opts.on("-d", "--daemonize", "Runs server in the background") { @action = :daemonize_server }
|
64
64
|
opts.on("-s", "--silence", "Logging disabled") { config.logging = false }
|
65
65
|
# actions
|
66
66
|
opts.on("-i", "--info", "Shows server configuration") { @action = :show_configuration }
|
@@ -76,7 +76,12 @@ module Emmy
|
|
76
76
|
config.group = "worker"
|
77
77
|
end
|
78
78
|
|
79
|
-
config.pid
|
79
|
+
config.pid ||= "#{config.backend}.pid"
|
80
|
+
config.log ||= "#{config.backend}.log"
|
81
|
+
if config.environment == "development"
|
82
|
+
config.stdout = "#{config.backend}.stdout"
|
83
|
+
config.stderr = config.stdout
|
84
|
+
end
|
80
85
|
end
|
81
86
|
|
82
87
|
def run_action
|
@@ -87,6 +92,20 @@ module Emmy
|
|
87
92
|
self
|
88
93
|
end
|
89
94
|
|
95
|
+
def daemonize_server
|
96
|
+
Process.fork do
|
97
|
+
Process.setsid
|
98
|
+
exit if fork
|
99
|
+
|
100
|
+
scope_pid(Process.pid) do |pid|
|
101
|
+
puts pid
|
102
|
+
File.umask(0000) # rw-rw-rw-
|
103
|
+
bind_standard_streams
|
104
|
+
start_server
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
90
109
|
def start_server
|
91
110
|
load backend_file
|
92
111
|
end
|
@@ -97,7 +116,9 @@ module Emmy
|
|
97
116
|
else
|
98
117
|
require 'irb'
|
99
118
|
require 'irb/completion'
|
100
|
-
|
119
|
+
EmmyMachine.run_block do
|
120
|
+
IRB.start
|
121
|
+
end
|
101
122
|
end
|
102
123
|
end
|
103
124
|
|
@@ -138,6 +159,30 @@ module Emmy
|
|
138
159
|
error "Can't find backend in #{backends.inspect} places."
|
139
160
|
end
|
140
161
|
|
162
|
+
def scope_pid(pid)
|
163
|
+
FileUtils.mkdir_p(File.dirname(config.pid))
|
164
|
+
File.open(config.pid, 'w') { |f| f.write(pid) }
|
165
|
+
if block_given?
|
166
|
+
yield pid
|
167
|
+
delete_pid
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def delete_pid
|
172
|
+
File.delete(config.pid)
|
173
|
+
end
|
174
|
+
|
175
|
+
def bind_standard_streams
|
176
|
+
STDIN.reopen("/dev/null")
|
177
|
+
STDOUT.reopen(config.stdout, "a")
|
178
|
+
|
179
|
+
if config.stdout == config.stderr
|
180
|
+
STDERR.reopen(STDOUT)
|
181
|
+
else
|
182
|
+
STDERR.reopen(config.stderr, "a")
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
141
186
|
#<<<
|
142
187
|
end
|
143
188
|
end
|
data/lib/emmy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emmy-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- inre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: emmy-machine
|