Why are unicorn creating multiple master processes on startup in production mode? -
okay im trying setup production serven unicorn.
when try start unicorn server thru script have written starts 2 master instance.
this happens when start "-e production" given.
the init scipt start unicorn with:
#!/bin/sh set -e timeout=${timeout-60} app_root=/application/path/current pid=$app_root/tmp/pids/unicorn.pid cmd="/usr/local/rvm/scripts/rvm && cd $app_root && bundle exec unicorn -d -e production -c $app_root/config/production/unicorn.rb" action="$1" set -u old_pid="$pid.oldbin" cd $app_root || exit 1 sig () { test -s "$pid" && kill -$1 `cat $pid` } oldsig () { test -s $old_pid && kill -$1 `cat $old_pid` } case $action in start) sig 0 && echo >&2 "already running" && exit 0 su -s /bin/bash -c "$cmd" - www-data ;; stop) sig quit && exit 0 echo >&2 "not running" ;; force-stop) sig term && exit 0 echo >&2 "not running" ;; restart|reload) sig hup && echo reloaded ok && exit 0 echo >&2 "couldn't reload, starting '$cmd' instead" su -s /bin/bash -c "$cmd" - www-data ;; upgrade) if sig usr2 && sleep 2 && sig 0 && oldsig quit n=$timeout while test -s $old_pid && test $n -ge 0 printf '.' && sleep 1 && n=$(( $n - 1 )) done echo if test $n -lt 0 && test -s $old_pid echo >&2 "$old_pid still exists after $timeout seconds" exit 1 fi exit 0 fi echo >&2 "couldn't upgrade, starting '$cmd' instead" su -s /bin/bash -c "$cmd" - www-data ;; reopen-logs) sig usr1 ;; *) echo >&2 "usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>" exit 1 ;; esac
uncorn config:
working_directory "/application/path/current" pid "/application/path/current/tmp/pids/unicorn.pid" stderr_path "/application/path/current/log/unicorn.log" stdout_path "/application/path/current/log/unicorn.log" listen "/application/path/current/tmp/unicorn.application_name.sock" worker_processes 1 timeout 30 before_fork |server, worker| defined?(activerecord::base) , activerecord::base.connection.disconnect! old_pid = "#{server.config[: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 end end end
would realy appreciate help!
edit: hum... appears tough if write command "ps aux | grep unicorn" states 2 processes (1 master , 1 worker) why dos htop state have 5 processes active (2 masters , 3 workers)?
htop
lists each thread of process separately, while ps
doesn't. please read this answer more details.
Comments
Post a Comment