Locate the Puma config file.

This commit is contained in:
cassiusChen 2013-11-18 12:53:36 +08:00
parent 6ff0f43703
commit f784a188c6
3 changed files with 44 additions and 0 deletions

View File

@ -54,6 +54,8 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
app.working_dir = rails_root
sockdir = "#{rails_root}/tmp/sockets"
File.directory? sockdir or FileUtils.mkdir_p sockdir
# Discourse is set to use Thin as its WebServer, here is its running scripts.
num_webs.times do |i|
app.process("thin-#{i}") do |process|
process.start_command = "bundle exec thin start -e production -t 0 --socket #{sockdir}/thin.#{i}.sock --pid #{rails_root}/tmp/pids/thin#{i}.pid --log #{rails_root}/log/thin-#{i}.log --daemonize"
@ -78,6 +80,28 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
end
end
# You can use Puma as WebServer as well, please use the scripts below.
#app.process("puma") do |process|
# process.start_command = "puma -e production -C #{rails_root}/config/puma.rb"
#
# # Puma's Setting file is located in config/puma.rb, if you want to edit them, go to puma.rb.
# # the upstream section in the nginx config to match.
# # The nginx.sample.conf file assumes you're using sockets.
#
# process.pid_file = "#{rails_root}/tmp/pids/puma.pid"
# process.start_grace_time = 30.seconds
# process.stop_grace_time = 10.seconds
# process.restart_grace_time = 10.seconds
# process.group = "pumas"
# process.uid = user
# process.gid = group
# process.daemonize = false
# process.stdout = process.stderr = "#{rails_root}/log/puma.log"
# # Thanks to: http://www.garrensmith.com/2012/09/24/Staying-up-with-Unicorn-Upstart-Bluepill.html
# # If the amount of memory is exceeded 3 times out of 5, restart
# process.checks :mem_usage, :every => 1.minutes, :below => 750.megabytes, :times => [3, 5]
#end
#debug instance
# app.process("thin-debug") do |process|
# process.start_command = "bundle exec thin start -e development -t 0 -p 10040 -P #{rails_root}/tmp/pids/thin-debug.pid -l #{rails_root}/log/thin-debug.log" -d"

View File

@ -10,6 +10,12 @@ upstream discourse {
server unix:/var/www/discourse/tmp/sockets/thin.3.sock;
}
# If you are going to use Puma, use these:
#
# upstream discourse {
# server unix:/var/www/discourse/tmp/sockets/puam.sock;
# }
server {
listen 80;

14
config/puma.rb Normal file
View File

@ -0,0 +1,14 @@
# First, you need to change these below to your situation.
APP_ROOT = '/home/discourse/discourse'
# Second, you can choose how many threads that you are going to run at same time.
workers 4
threads 8,32
# Unless you know what you are changing, do not change them.
bind "unix://#{APP_ROOT}/tmp/sockets/puma.sock"
stdout_redirect "#{APP_ROOT}/log/puma.log","#{APP_ROOT}/log/puma.err.log"
pidfile "#{APP_ROOT}/tmp/pids/puma.pid"
state_path "#{APP_ROOT}/tmp/pids/puma.state"
daemonize true
preload_app!