ruby on rails - How to restart unicorn and nginx after deployment? -


i pretty new these new tools - unicorn , nginx - , i'd ask you, how restart them after development. far, have setup:

unicorn_ini.sh

set -e  # feel free change of following variables app: timeout=${timeout-60} app_root=/home/deployer/apps/project/current pid=$app_root/tmp/pids/unicorn.pid cmd="cd $app_root; bundle exec unicorn -d -c $app_root/config/unicorn.rb -e production" as_user=deployer set -u  old_pin="$pid.oldbin"  sig () {   test -s "$pid" && kill -$1 `cat $pid` }  oldsig () {   test -s $old_pin && kill -$1 `cat $old_pin` }  run () {   if [ "$(id -un)" = "$as_user" ];     eval $1   else     su -c "$1" - $as_user   fi }  case "$1" in start)   sig 0 && echo >&2 "already running" && exit 0   run "$cmd"   ;; 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"   run "$cmd"   ;; upgrade)   if sig usr2 && sleep 2 && sig 0 && oldsig quit       n=$timeout     while test -s $old_pin && test $n -ge 0           printf '.' && sleep 1 && n=$(( $n - 1 ))     done     echo      if test $n -lt 0 && test -s $old_pin           echo >&2 "$old_pin still exists after $timeout seconds"       exit 1     fi     exit 0   fi   echo >&2 "couldn't upgrade, starting '$cmd' instead"   run "$cmd"   ;; reopen-logs)   sig usr1   ;; *)   echo >&2 "usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"   exit 1   ;; esac 

unicorn.rb

root = "/home/deployer/apps/project/current" working_directory root pid "#{root}/tmp/pids/unicorn.pid" stderr_path "#{root}/log/unicorn.log" stdout_path "#{root}/log/unicorn.log"  listen "/tmp/unicorn.project.sock" worker_processes 4 timeout 30  # force bundler gemfile environment variable # reference capistrano "current" symlink before_exec |_|   env["bundle_gemfile"] = file.join(root, 'gemfile') end 

deploy.rb

lock '3.2.1'  set :application, 'project' set :scm, :git  set :repo_url, 'git@bitbucket.org:me/project.git'  set :pty, true set :deploy_to, "/home/deployer/apps/project"  set :keep_releases, 5  namespace :deploy    desc 'restart application'   task :restart     on roles(:app), in: :sequence, wait: 5       # restart mechanism here, example:       # execute :touch, release_path.join('tmp/restart.txt')     end   end    after :publishing, :restart    after :restart, :clear_cache     on roles(:web), in: :groups, limit: 3, wait: 10       # here can such as:       # within release_path       #   execute :rake, 'cache:clear'       # end     end   end  end 

this current setup. restarted after successful deployment nginx , unicorn, i'd see new code deployed? also, application bundled?

thank you, , sorry once again - ma doing first time

you consider use https://github.com/tablexi/capistrano3-unicorn, allow have 0 down time deployment, restart unicorns, 0 setup needed.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -