server-starter 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/bin/start_puma.rb +17 -0
- data/example/puma/Gemfile +6 -0
- data/example/puma/config/puma.conf.rb +54 -0
- data/example/{config.ru → puma/config.ru} +0 -0
- data/example/{env → puma/env}/TEST +0 -0
- data/example/{log → puma/log}/.gitkeep +0 -0
- data/example/{restart_server → puma/restart_server} +0 -0
- data/example/puma/start_server +16 -0
- data/example/{Gemfile → unicorn/Gemfile} +1 -1
- data/example/{config → unicorn/config}/unicorn.conf +1 -1
- data/example/unicorn/config.ru +11 -0
- data/example/unicorn/env/TEST +1 -0
- data/example/unicorn/log/.gitkeep +0 -0
- data/example/unicorn/restart_server +2 -0
- data/example/{start_server → unicorn/start_server} +0 -0
- data/lib/server/starter/puma_listener.rb +9 -0
- data/lib/server/starter/version.rb +1 -1
- metadata +18 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8b2e1016a56a58b14b4aeaaa37823b343816a5f
|
4
|
+
data.tar.gz: 85ec3da094558506221d980a185f7a2dcb8e79f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 671005c01b169fa2c415f93ccd12817b80ccd938aca82355313f74465419d93d188624353a0d94be77dc30a9b6f4bef397364b6c64fc2b80fa854b45d3eac886
|
7
|
+
data.tar.gz: 74d3bcc535fa7d3613f9e68369d467603b85640269eee77821baa3ca6c85ef6a186e6d871cd3f14b672407b4095e2fc8d5c46b25df671efad89a8f141a5f963d
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/bin/start_puma.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
if ENV.key?('SERVER_STARTER_PORT')
|
4
|
+
ENV['SERVER_STARTER_PORT'].split(';').each.with_index do |x, i|
|
5
|
+
path_or_port, fd = x.split('=', 2)
|
6
|
+
if path_or_port.match(/(?:^|:)\d+$/)
|
7
|
+
url = "tcp://#{path_or_port}"
|
8
|
+
else
|
9
|
+
url = "unix://#{path_or_port}"
|
10
|
+
end
|
11
|
+
ENV["PUMA_INHERIT_#{i}"] = "#{fd}:#{url}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
args = ARGV.dup
|
16
|
+
args << { :close_others => false }
|
17
|
+
Kernel.exec(*args)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
APP_ROOT = File.expand_path('../..', __FILE__)
|
2
|
+
status_file = File.join(APP_ROOT, 'log/start_server.stat')
|
3
|
+
|
4
|
+
pidfile File.join(APP_ROOT, 'log/puma.pid')
|
5
|
+
state_path File.join(APP_ROOT, 'log/puma.state')
|
6
|
+
|
7
|
+
# prune_bundler # need to tweak lib/puma/launher to add { close_others: false } opts to Kernel.exec
|
8
|
+
preload_app!
|
9
|
+
|
10
|
+
# Configure "min" to be the minimum number of threads to use to answer
|
11
|
+
# requests and "max" the maximum.
|
12
|
+
# The default is "0, 16".
|
13
|
+
threads 0, 16
|
14
|
+
|
15
|
+
# How many worker processes to run. The default is "0".
|
16
|
+
workers 2
|
17
|
+
|
18
|
+
# Run puma via start_puma.rb to configure PUMA_INHERIT_\d ENV from SERVER_STARTER_PORT ENV as
|
19
|
+
# $ bundle exec --keep-file-descriptors start_puma.rb puma -C config/puma.conf.rb config.ru
|
20
|
+
if ENV['PUMA_INHERIT_0']
|
21
|
+
ENV.each do |k,v|
|
22
|
+
if k =~ /PUMA_INHERIT_\d+/
|
23
|
+
fd, url = v.split(":", 2)
|
24
|
+
bind url
|
25
|
+
end
|
26
|
+
end
|
27
|
+
else
|
28
|
+
# Fallback if not running under Server::Starter
|
29
|
+
bind 'tcp://0.0.0.0:10080'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Code to run before doing a restart. This code should
|
33
|
+
# close log files, database connections, etc.
|
34
|
+
# This can be called multiple times to add code each time.
|
35
|
+
on_restart do
|
36
|
+
puts 'On restart...'
|
37
|
+
end
|
38
|
+
|
39
|
+
# Code to run when a worker boots to setup the process before booting
|
40
|
+
# the app. This can be called multiple times to add hooks.
|
41
|
+
on_worker_boot do
|
42
|
+
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
43
|
+
end
|
44
|
+
|
45
|
+
# Code to run when a worker boots to setup the process after booting
|
46
|
+
# the app. This can be called multiple times to add hooks.
|
47
|
+
after_worker_boot do
|
48
|
+
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
|
49
|
+
end
|
50
|
+
|
51
|
+
# Code to run when a worker shutdown.
|
52
|
+
on_worker_shutdown do
|
53
|
+
puts 'On worker shutdown...'
|
54
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
bundle exec start_server.rb \
|
3
|
+
--port=0.0.0.0:10080 \
|
4
|
+
--dir=$(pwd) \
|
5
|
+
--interval=1 \
|
6
|
+
--signal-on-hup=TERM \
|
7
|
+
--signal-on-TERM=TERM \
|
8
|
+
--pid-file=$(pwd)/log/start_server.pid \
|
9
|
+
--status-file=$(pwd)/log/start_server.stat \
|
10
|
+
--envdir=env \
|
11
|
+
--enable-auto-restart \
|
12
|
+
--auto-restart-interval=100 \
|
13
|
+
--kill-old-delay=10 \
|
14
|
+
--backlog=100 \
|
15
|
+
-- \
|
16
|
+
bundle exec --keep-file-descriptors start_puma.rb puma -C config/puma.conf.rb config.ru 2>&1
|
@@ -7,7 +7,7 @@ preload_app true
|
|
7
7
|
APP_ROOT = File.expand_path('../..', __FILE__)
|
8
8
|
status_file = File.join(APP_ROOT, 'log/start_server.stat')
|
9
9
|
|
10
|
-
fd = listener.listen
|
10
|
+
fd = listener.listen # Configure UNICORN_FD ENV
|
11
11
|
unless fd
|
12
12
|
# Fallback if not running under Server::Starter
|
13
13
|
listen ENV['PORT'] || '10080'
|
@@ -0,0 +1 @@
|
|
1
|
+
foo
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: server-starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
@@ -28,6 +28,7 @@ description: a superdaemon for hot-deploying server programs (ruby port of p5-Se
|
|
28
28
|
email:
|
29
29
|
- sonots@gmail.com
|
30
30
|
executables:
|
31
|
+
- start_puma.rb
|
31
32
|
- start_server.rb
|
32
33
|
extensions: []
|
33
34
|
extra_rdoc_files: []
|
@@ -38,16 +39,25 @@ files:
|
|
38
39
|
- LICENSE
|
39
40
|
- README.md
|
40
41
|
- Rakefile
|
42
|
+
- bin/start_puma.rb
|
41
43
|
- bin/start_server.rb
|
42
|
-
- example/Gemfile
|
43
|
-
- example/config.ru
|
44
|
-
- example/config/
|
45
|
-
- example/env/TEST
|
46
|
-
- example/log/.gitkeep
|
47
|
-
- example/restart_server
|
48
|
-
- example/start_server
|
44
|
+
- example/puma/Gemfile
|
45
|
+
- example/puma/config.ru
|
46
|
+
- example/puma/config/puma.conf.rb
|
47
|
+
- example/puma/env/TEST
|
48
|
+
- example/puma/log/.gitkeep
|
49
|
+
- example/puma/restart_server
|
50
|
+
- example/puma/start_server
|
51
|
+
- example/unicorn/Gemfile
|
52
|
+
- example/unicorn/config.ru
|
53
|
+
- example/unicorn/config/unicorn.conf
|
54
|
+
- example/unicorn/env/TEST
|
55
|
+
- example/unicorn/log/.gitkeep
|
56
|
+
- example/unicorn/restart_server
|
57
|
+
- example/unicorn/start_server
|
49
58
|
- lib/server/starter.rb
|
50
59
|
- lib/server/starter/helper.rb
|
60
|
+
- lib/server/starter/puma_listener.rb
|
51
61
|
- lib/server/starter/unicorn_listener.rb
|
52
62
|
- lib/server/starter/version.rb
|
53
63
|
- server-starter.gemspec
|