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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68c36a989a31dbedc64dbf0151ae27ba31b62423
4
- data.tar.gz: 4cf2050173783280a3c4a0f649af09badb8715b6
3
+ metadata.gz: c8b2e1016a56a58b14b4aeaaa37823b343816a5f
4
+ data.tar.gz: 85ec3da094558506221d980a185f7a2dcb8e79f9
5
5
  SHA512:
6
- metadata.gz: 4f40f2dfcb2b27c656948cabd4971dfec25ecc190fbce8373c0483736bac0c19396be8afa46e19657cca01f8bedb5bca67ff7587933c006ab382fe1123dc236a
7
- data.tar.gz: b5e563e113f13c990aefae3a29caa4d638a289d44ed3fc94d284c2da9c56645a87fac77de13f3c16501b7675eb3233490e274ffafb67edd216a6287a642579d0
6
+ metadata.gz: 671005c01b169fa2c415f93ccd12817b80ccd938aca82355313f74465419d93d188624353a0d94be77dc30a9b6f4bef397364b6c64fc2b80fa854b45d3eac886
7
+ data.tar.gz: 74d3bcc535fa7d3613f9e68369d467603b85640269eee77821baa3ca6c85ef6a186e6d871cd3f14b672407b4095e2fc8d5c46b25df671efad89a8f141a5f963d
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ pkg/*
16
16
  start_server.stat
17
17
  start_server.pid
18
18
  start_server.log
19
+ puma.state
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.0 (2016/04/03)
2
+
3
+ Enhancements:
4
+
5
+ * Add puma support
6
+
1
7
  ## 0.1.5 (2016/04/03)
2
8
 
3
9
  Fixes:
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,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'server-starter', path: '../../'
4
+ gem 'puma'
5
+ gem 'pry'
6
+ gem 'pry-nav'
@@ -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
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'server-starter', path: '../'
3
+ gem 'server-starter', path: '../../'
4
4
  gem 'unicorn'
5
5
  gem 'pry'
6
6
  gem 'pry-nav'
@@ -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,11 @@
1
+ class SimpleApp
2
+ def call(env)
3
+ [
4
+ 200,
5
+ {'Content-Type' => 'text/html'},
6
+ ['Hello World']
7
+ ]
8
+ end
9
+ end
10
+
11
+ run SimpleApp.new
@@ -0,0 +1 @@
1
+ foo
File without changes
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ bundle exec start_server.rb --restart --pid-file=log/start_server.pid --status-file=log/start_server.stat
File without changes
@@ -0,0 +1,9 @@
1
+ require 'server/starter/version'
2
+
3
+ class Server::Starter
4
+ class PumaListener
5
+ def self.listen
6
+ $stderr.puts "Configure ENV in config seems too late. Use start_puma.rb instead"
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  class Server
2
2
  class Starter
3
- VERSION = '0.1.5'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
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.1.5
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/unicorn.conf
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