Make listen directive for Unicorn configurable
This commit is contained in:
parent
a396a246ee
commit
a21de8b190
4 changed files with 45 additions and 45 deletions
|
|
@ -32,7 +32,8 @@ defaults:
|
||||||
host:
|
host:
|
||||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||||
server:
|
server:
|
||||||
port: 3000
|
port:
|
||||||
|
listen: '0.0.0.0:3000'
|
||||||
rails_environment: 'development'
|
rails_environment: 'development'
|
||||||
stderr_log:
|
stderr_log:
|
||||||
stdout_log:
|
stdout_log:
|
||||||
|
|
|
||||||
|
|
@ -140,8 +140,13 @@ configuration: ## Section
|
||||||
|
|
||||||
## Settings affecting how ./script/server behaves.
|
## Settings affecting how ./script/server behaves.
|
||||||
server: ## Section
|
server: ## Section
|
||||||
|
## Where the appserver should listen to (default=0.0.0.0:3000)
|
||||||
|
#listen: '127.0.0.1:3000'
|
||||||
|
#listen: 'unix:tmp/diaspora.sock'
|
||||||
|
#listen: 'unix:/run/diaspora/diaspora.sock'
|
||||||
|
|
||||||
## The port on which the appserver should listen (default=3000).
|
## The port on which the appserver should listen (default=none).
|
||||||
|
## Note: this setting is deprecated, use listen instead.
|
||||||
#port: 3000
|
#port: 3000
|
||||||
|
|
||||||
## Rails environment (default='development').
|
## Rails environment (default='development').
|
||||||
|
|
@ -407,14 +412,14 @@ configuration: ## Section
|
||||||
## **or** an encrypted key for an unhosted button.
|
## **or** an encrypted key for an unhosted button.
|
||||||
paypal_donations: ## Section
|
paypal_donations: ## Section
|
||||||
#enable: false
|
#enable: false
|
||||||
|
|
||||||
## Currency used (USD, EUR...)
|
## Currency used (USD, EUR...)
|
||||||
#currency: USD
|
#currency: USD
|
||||||
|
|
||||||
## hosted Paypal button id
|
## hosted Paypal button id
|
||||||
#paypal_hosted_button_id: "change_me"
|
#paypal_hosted_button_id: "change_me"
|
||||||
## OR encrypted key of unhosted button
|
## OR encrypted key of unhosted button
|
||||||
#paypal_unhosted_button_encrypted: "-----BEGIN PKCS7-----"
|
#paypal_unhosted_button_encrypted: "-----BEGIN PKCS7-----"
|
||||||
|
|
||||||
## Bitcoin donations
|
## Bitcoin donations
|
||||||
## You can provide a bitcoin address here to allow your users to provide
|
## You can provide a bitcoin address here to allow your users to provide
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,19 @@
|
||||||
require File.expand_path('../load_config', __FILE__)
|
require_relative "load_config"
|
||||||
|
|
||||||
# Enable and set these to run the worker as a different user/group
|
port = ENV["PORT"]
|
||||||
#user = 'diaspora'
|
port = port && !port.empty? ? port.to_i : nil
|
||||||
#group = 'diaspora'
|
|
||||||
|
|
||||||
|
listen port || AppConfig.server.listen.get unless RACKUP[:set_listener]
|
||||||
worker_processes AppConfig.server.unicorn_worker.to_i
|
worker_processes AppConfig.server.unicorn_worker.to_i
|
||||||
|
|
||||||
## Load the app before spawning workers
|
|
||||||
preload_app true
|
|
||||||
|
|
||||||
# How long to wait before killing an unresponsive worker
|
|
||||||
timeout AppConfig.server.unicorn_timeout.to_i
|
timeout AppConfig.server.unicorn_timeout.to_i
|
||||||
|
|
||||||
@sidekiq_pid = nil
|
|
||||||
|
|
||||||
#pid '/var/run/diaspora/diaspora.pid'
|
|
||||||
#listen '/var/run/diaspora/diaspora.sock', :backlog => 2048
|
|
||||||
|
|
||||||
|
|
||||||
stderr_path AppConfig.server.stderr_log.get if AppConfig.server.stderr_log?
|
stderr_path AppConfig.server.stderr_log.get if AppConfig.server.stderr_log?
|
||||||
stdout_path AppConfig.server.stdout_log.get if AppConfig.server.stdout_log?
|
stdout_path AppConfig.server.stdout_log.get if AppConfig.server.stdout_log?
|
||||||
|
|
||||||
before_fork do |server, worker|
|
preload_app true
|
||||||
# If using preload_app, enable this line
|
@sidekiq_pid = nil
|
||||||
ActiveRecord::Base.connection.disconnect!
|
|
||||||
|
before_fork do |_server, _worker|
|
||||||
|
ActiveRecord::Base.connection.disconnect! # preloading app in master, so reconnect to DB
|
||||||
|
|
||||||
# disconnect redis if in use
|
# disconnect redis if in use
|
||||||
unless AppConfig.environment.single_process_mode?
|
unless AppConfig.environment.single_process_mode?
|
||||||
|
|
@ -31,23 +21,12 @@ before_fork do |server, worker|
|
||||||
end
|
end
|
||||||
|
|
||||||
if AppConfig.server.embed_sidekiq_worker?
|
if AppConfig.server.embed_sidekiq_worker?
|
||||||
@sidekiq_pid ||= spawn('bin/bundle exec sidekiq')
|
@sidekiq_pid ||= spawn("bin/bundle exec sidekiq")
|
||||||
end
|
|
||||||
|
|
||||||
old_pid = '/var/run/diaspora/diaspora.pid.oldbin'
|
|
||||||
if File.exists?(old_pid) && server.pid != old_pid
|
|
||||||
begin
|
|
||||||
Process.kill("QUIT", File.read(old_pid).to_i)
|
|
||||||
rescue Errno::ENOENT, Errno::ESRCH
|
|
||||||
# someone else did our job for us
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
after_fork do |_server, _worker|
|
||||||
after_fork do |server, worker|
|
ActiveRecord::Base.establish_connection # preloading app in master, so reconnect to DB
|
||||||
# If using preload_app, enable this line
|
|
||||||
ActiveRecord::Base.establish_connection
|
|
||||||
|
|
||||||
# We don't generate uuids in the frontend, but let's be on the safe side
|
# We don't generate uuids in the frontend, but let's be on the safe side
|
||||||
UUID.generator.next_sequence
|
UUID.generator.next_sequence
|
||||||
|
|
|
||||||
|
|
@ -119,17 +119,28 @@ then
|
||||||
export DB
|
export DB
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$PORT" -a -n "$port" ]
|
||||||
|
then
|
||||||
|
warning "Setting port via configuration is deprecated, set listen instead. See the updated config/diaspora.yml.example."
|
||||||
|
PORT="$port"
|
||||||
|
fi
|
||||||
|
|
||||||
args="$@"
|
args="$@"
|
||||||
for arg in $(echo $args | awk '{ for (i = 1; i <= NF; i++) print $i}')
|
for arg in $(echo $args | awk '{ for (i = 1; i <= NF; i++) print $i}')
|
||||||
do
|
do
|
||||||
[ "$prev_arg" = '-p' ] && port="$arg"
|
[ "$prev_arg" = '-p' ] && PORT="$arg"
|
||||||
prev_arg="$arg"
|
prev_arg="$arg"
|
||||||
done
|
done
|
||||||
|
|
||||||
services=$(chk_service $port )
|
if [ -n "$PORT" ]
|
||||||
if [ -n "$services" ]
|
|
||||||
then
|
then
|
||||||
fatal "Port $port is already in use.\n\t$services"
|
export PORT
|
||||||
|
|
||||||
|
services=$(chk_service $PORT)
|
||||||
|
if [ -n "$services" ]
|
||||||
|
then
|
||||||
|
fatal "Port $port is already in use.\n\t$services"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Force AGPL
|
# Force AGPL
|
||||||
|
|
@ -186,11 +197,15 @@ think about editing your proxy configuration as described in:
|
||||||
diaspora.yml.example
|
diaspora.yml.example
|
||||||
*****************************************************************
|
*****************************************************************
|
||||||
"
|
"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start Diaspora
|
# Start Diaspora
|
||||||
printf "Starting Diaspora in $RAILS_ENV mode on port $port "
|
printf "Starting Diaspora in $RAILS_ENV mode "
|
||||||
|
if [ -n "$PORT" ]
|
||||||
|
then
|
||||||
|
printf "on port $PORT "
|
||||||
|
port_option="-p $PORT"
|
||||||
|
fi
|
||||||
if [ "$embed_sidekiq_worker" = "true" ]
|
if [ "$embed_sidekiq_worker" = "true" ]
|
||||||
then
|
then
|
||||||
echo "with a Sidekiq worker embedded into Unicorn."
|
echo "with a Sidekiq worker embedded into Unicorn."
|
||||||
|
|
@ -204,4 +219,4 @@ else
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
exec bin/bundle exec foreman start -m "xmpp=$vines,web=1,sidekiq=$workers" -p $port
|
exec bin/bundle exec foreman start -m "xmpp=$vines,web=1,sidekiq=$workers" $port_option
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue