Skip to content

Commit 2de0f44

Browse files
committed
try puma server
1 parent c17d4da commit 2de0f44

File tree

5 files changed

+187
-30
lines changed

5 files changed

+187
-30
lines changed

Gemfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ source 'http://rubygems.org'
22

33
# Project requirements
44
gem 'rake'
5+
gem 'tilt', '~> 1.3.7'
56
gem 'padrino-core', '~> 0.11'
67
gem 'padrino-helpers', '~> 0.11'
78

@@ -20,16 +21,16 @@ gem 'sanitize'
2021
gem 'carrierwave', :require => ['carrierwave', 'carrierwave/orm/activerecord']
2122
gem 'mini_magick'
2223
gem 'rest-client'
24+
gem 'puma'
2325

2426
# Production requirements
25-
group :production do
26-
gem 'rainbows'
27-
end
27+
# group :production do
28+
# gem 'rainbows'
29+
# end
2830

2931
# Development requirements
3032
group :development do
31-
gem 'thin'
32-
gem 'pry'
33+
gem 'pry-padrino'
3334
gem 'padrino-gen', '~> 0.11'
3435
end
3536

Gemfile.lock

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
GIT
22
remote: git://github.com/csdn-dev/second_level_cache.git
3-
revision: 4ea270ded9b64e83f4b382b2ea884606603510a6
3+
revision: f6185488ebf1bf5d1e7e18e1448c61bb367f51d2
44
specs:
5-
second_level_cache (1.6.1)
5+
second_level_cache (1.6.2)
66
activesupport (~> 3.2.0)
77

88
GIT
@@ -33,11 +33,9 @@ GEM
3333
activemodel (>= 3.2.0)
3434
activesupport (>= 3.2.0)
3535
coderay (1.0.9)
36-
daemons (1.1.9)
37-
dalli (2.6.2)
36+
dalli (2.6.3)
3837
database_cleaner (0.9.1)
3938
erubis (2.7.0)
40-
eventmachine (1.0.3)
4139
factory_girl (4.2.0)
4240
activesupport (>= 3.0.0)
4341
github-markdown (0.5.3)
@@ -47,11 +45,11 @@ GEM
4745
i18n (0.6.4)
4846
kgio (2.8.0)
4947
method_source (0.8.1)
50-
mime-types (1.22)
48+
mime-types (1.23)
5149
mini_magick (3.5.0)
5250
subexec (~> 0.2.1)
5351
minitest (2.6.2)
54-
multi_json (1.7.2)
52+
multi_json (1.7.3)
5553
mysql2 (0.3.11)
5654
nokogiri (1.5.9)
5755
padrino-core (0.11.1)
@@ -67,20 +65,19 @@ GEM
6765
padrino-helpers (0.11.1)
6866
i18n (~> 0.6)
6967
padrino-core (= 0.11.1)
70-
pry (0.9.12)
68+
pry (0.9.12.1)
7169
coderay (~> 1.0.5)
7270
method_source (~> 0.8)
7371
slop (~> 3.4)
72+
pry-padrino (0.1.2)
73+
pry (>= 0.8)
74+
puma (2.0.1)
75+
rack (>= 1.1, < 2.0)
7476
rack (1.5.2)
7577
rack-protection (1.5.0)
7678
rack
7779
rack-test (0.6.2)
7880
rack (>= 1.0)
79-
rainbows (4.5.0)
80-
kgio (~> 2.5)
81-
rack (~> 1.1)
82-
unicorn (~> 4.6, >= 4.6.2)
83-
raindrops (0.10.0)
8481
rake (10.0.4)
8582
rest-client (1.6.7)
8683
mime-types (>= 1.16)
@@ -91,18 +88,10 @@ GEM
9188
rack-protection (~> 1.4)
9289
tilt (~> 1.3, >= 1.3.4)
9390
slop (3.4.4)
94-
subexec (0.2.2)
95-
thin (1.5.1)
96-
daemons (>= 1.0.9)
97-
eventmachine (>= 0.12.6)
98-
rack (>= 1.0.0)
91+
subexec (0.2.3)
9992
thor (0.17.0)
10093
tilt (1.3.7)
10194
tzinfo (0.3.37)
102-
unicorn (4.6.2)
103-
kgio (~> 2.6)
104-
rack
105-
raindrops (~> 0.7)
10695
url_mount (0.2.1)
10796
rack
10897
will_paginate (3.0.4)
@@ -127,12 +116,12 @@ DEPENDENCIES
127116
padrino-core (~> 0.11)
128117
padrino-gen (~> 0.11)
129118
padrino-helpers (~> 0.11)
130-
pry
119+
pry-padrino
120+
puma
131121
rack-test
132-
rainbows
133122
rake
134123
rest-client
135124
sanitize
136125
second_level_cache!
137-
thin
126+
tilt (~> 1.3.7)
138127
will_paginate

config/puma.rb

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
#!/usr/bin/env puma
2+
3+
# The directory to operate out of.
4+
#
5+
# The default is the current directory.
6+
#
7+
# directory '/u/apps/lolcat'
8+
9+
# Use a object or block as the rack application. This allows the
10+
# config file to be the application itself.
11+
#
12+
# app do |env|
13+
# puts env
14+
#
15+
# body = 'Hello, World!'
16+
#
17+
# [200, { 'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
18+
# end
19+
20+
# Load “path” as a rackup file.
21+
#
22+
# The default is “config.ru”.
23+
#
24+
# rackup '/u/apps/lolcat/config.ru'
25+
26+
# Set the environment in which the rack's app will run. The value must be a string.
27+
#
28+
# The default is “development”.
29+
#
30+
environment 'production'
31+
32+
# Daemonize the server into the background. Highly suggest that
33+
# this be combined with “pidfile” and “stdout_redirect”.
34+
#
35+
# The default is “false”.
36+
#
37+
# daemonize
38+
daemonize true
39+
40+
wd = File.expand_path('../../', __FILE__)
41+
tmp_path = File.join(wd, 'log')
42+
Dir.mkdir(tmp_path) unless File.exist?(tmp_path)
43+
44+
pidfile File.join(tmp_path, 'puma.pid')
45+
state_path File.join(tmp_path, 'puma.state')
46+
stdout_redirect File.join(tmp_path, 'puma.out.log'), File.join(tmp_path, 'puma.err.log'), true
47+
48+
# Store the pid of the server in the file at “path”.
49+
#
50+
# pidfile '/u/apps/lolcat/tmp/pids/puma.pid'
51+
52+
# Use “path” as the file to store the server info state. This is
53+
# used by “pumactl” to query and control the server.
54+
#
55+
# state_path '/u/apps/lolcat/tmp/pids/puma.state'
56+
57+
# Redirect STDOUT and STDERR to files specified. The 3rd parameter
58+
# (“append”) specifies whether the output is appended, the default is
59+
# “false”.
60+
#
61+
# stdout_redirect '/u/apps/lolcat/log/stdout', '/u/apps/lolcat/log/stderr'
62+
# stdout_redirect '/u/apps/lolcat/log/stdout', '/u/apps/lolcat/log/stderr', true
63+
64+
# Disable request logging.
65+
#
66+
# The default is “false”.
67+
#
68+
# quiet
69+
70+
# Configure “min” to be the minimum number of threads to use to answer
71+
# requests and “max” the maximum.
72+
#
73+
# The default is “0, 16”.
74+
#
75+
threads 0, 16
76+
77+
# Bind the server to “url”. “tcp://”, “unix://” and “ssl://” are the only
78+
# accepted protocols.
79+
#
80+
# The default is “tcp://0.0.0.0:9292”.
81+
#
82+
bind 'tcp://0.0.0.0:8080'
83+
# bind 'unix:///var/run/puma.sock'
84+
# bind 'unix:///var/run/puma.sock?umask=0777'
85+
# bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
86+
87+
# Instead of “bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'” you
88+
# can also use the “ssl_bind” option.
89+
#
90+
# ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert }
91+
92+
# Code to run before doing a restart. This code should
93+
# close log files, database connections, etc.
94+
#
95+
# This can be called multiple times to add code each time.
96+
#
97+
# on_restart do
98+
# puts 'On restart...'
99+
# end
100+
101+
# Command to use to restart puma. This should be just how to
102+
# load puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments
103+
# to puma, as those are the same as the original process.
104+
#
105+
# restart_command '/u/app/lolcat/bin/restart_puma'
106+
107+
# === Cluster mode ===
108+
109+
# How many worker processes to run.
110+
#
111+
# The default is “0”.
112+
#
113+
workers 0
114+
115+
# Code to run when a worker boots to setup the process before booting
116+
# the app.
117+
#
118+
# This can be called multiple times to add hooks.
119+
#
120+
# on_worker_boot do
121+
# puts 'On worker boot...'
122+
# end
123+
124+
# === Puma control rack application ===
125+
126+
# Start the puma control rack application on “url”. This application can
127+
# be communicated with to control the main server. Additionally, you can
128+
# provide an authentication token, so all requests to the control server
129+
# will need to include that token as a query parameter. This allows for
130+
# simple authentication.
131+
#
132+
# Check out https://github.com/puma/puma/blob/master/lib/puma/app/status.rb
133+
# to see what the app has available.
134+
#
135+
# activate_control_app 'unix:///var/run/pumactl.sock'
136+
# activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345' }
137+
# activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true }

puma.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# set ruby GC parameters
4+
RUBY_HEAP_MIN_SLOTS=600000
5+
RUBY_FREE_MIN=200000
6+
RUBY_GC_MALLOC_LIMIT=60000000
7+
export RUBY_HEAP_MIN_SLOTS RUBY_FREE_MIN RUBY_GC_MALLOC_LIMIT
8+
9+
state_file="log/puma.state"
10+
11+
case "$1" in
12+
start)
13+
bundle exec puma -C config/puma.rb
14+
;;
15+
stop)
16+
bundle exec pumactl -S $state_file stop
17+
;;
18+
restart)
19+
bundle exec pumactl -S $state_file restart
20+
;;
21+
status)
22+
bundle exec pumactl -S $state_file status
23+
;;
24+
force-stop)
25+
bundle exec pumactl -S $state_file halt
26+
;;
27+
*)
28+
echo $"Usage: $0 {start|stop|force-stop|restart|status}"
29+
;;
30+
esac
File renamed without changes.

0 commit comments

Comments
 (0)