Giter VIP home page Giter VIP logo

capistrano-unicorn's People

Contributors

aspiers avatar astropanic avatar bmorearty avatar chip avatar docwhat avatar dtaniwaki avatar gekola avatar gilest avatar iamruinous avatar irohiroki avatar jasiek avatar jeroenhouben avatar lidaobing avatar maxim-filimonov avatar mcrowe avatar mifix avatar mikesmullin avatar nhoffmann avatar prognostikos avatar sfsekaran avatar sosedoff avatar tonkpils avatar vsizov avatar zacharydanger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

capistrano-unicorn's Issues

Disable set -x debugging option

Due to the set -x option I got 'unicorn.reload' and 'unicorn:restart' deployment tasks to output some data that is interpreted by Capistrano as errors. The deployment works fine, but it would be nice to remove this behavior in favor of visual error detection.

screen shot 2013-09-19 at 12 07 37

Add tests

With more functionality comes more confusion. This project has grown into something that needs tests to continue improving. Otherwise it'll become (or already did) a complete mess.

Test/start unicorn in development mode

So I was trying to get my unicorn setup right and wanted to try this on my development machine but realised this gem doesn't come with a way (or at least not well documented one) for running unicorn using the config file in config/unicorn/development.rb

Manage unicorn via init

After having a Linode go down unexpectedly, I realized how much I miss having init control my unicorn service so that it will come back up on system restart.

I used to do this using moonshine and moonshine_unicorn, but moonshine expects a single app per server and imposes a lot of other related constraints, which is why I moved to capistrano-unicorn.

Because I miss using init so much, I created capistrano-unicorn-init, which does more or less what this gem does except that it uses init to manage unicorn.

Is there any appetite for merging this init-based solution into this project? Or is it best that I maintain a separate gem for this? What's the advantage of not using init?

@sfsekaran @DavidAllison I enjoyed our conversation on #40. I'm curious to hear what you think of going the init route.

capistrano-unicorn with capistrano 3.x

Hi, I have rewritten capistrano-unicorn to work with capistrano 3.x, check out sepastian-capistrano-unicorn.

This is still in an early stage and not at all tested; but I can use it to deploy my projects with capistrano 3.x. Some changes I made:

  • The run command is no longer available; instead, execute (SSHKit) must be used.

    One issue with that was multiline (here-doc) scripts, as used in capistrano-unicorn. Commands will be sanitized by SSHKit before execution. During sanitization, all line breaks will be replaced with semicolons. This, in turn, renders some shell scripts invalid. To overcome this, I did script.split.join(' ').

  • Capistrano 3.x defines a special tasks for loading default settings, namely load:defaults. See also capistrano/capistrano#605. So the contents of config.rb is now in capistrano/tasks/unicorn.cap, inside the load:defaults task.

  • In Capistrano 3.x, set does no longer accept a block. Instead, a Proc must be specified. So set :abc { ... } becomes set :abc, Proc.new{ ... }.

  • defer no longer exists in Capistrano 3.x.

Could you please have a look at this? What are you plans for supporting capistrano 3.x? Thoughts? How about creating a new branch for capistrano 3.x support?

sudo: bundle: command not found, Compatible with RVM?

I'm trying to get RVM, capistrano and unicorn to place nice together with a multistage setup. I'm currently getting this:

joshua@ccubuntu:~/collaborase/current$ cap unicorn:start
triggering load callbacks
* 2013-07-15 19:56:06 executing `staging'
triggering start callbacks for `unicorn:start'
* 2013-07-15 19:56:07 executing `multistage:ensure'
* 2013-07-15 19:56:07 executing `unicorn:start'
  triggering before callbacks for `unicorn:start'
* executing "if [ -e /home/staging/capistrano/current/config/unicorn.rb ]; then\\\n              UNICORN_CONFIG_PATH=/home/staging/capistrano/current/config/unicorn.rb;\\\n            else\\\n              if [ -e /home/staging/capistrano/current/config/unicorn/staging.rb ]; then\\\n                UNICORN_CONFIG_PATH=/home/staging/capistrano/current/config/unicorn/staging.rb;\\\n              else\\\n                echo \"Config file for \"staging\" environment was not found at either \"/home/staging/capistrano/current/config/unicorn.rb\" or \"/home/staging/capistrano/current/config/unicorn/staging.rb\"\";\\\n                exit 1;\\\n              fi;\\\n            fi;\\\n\\\n            if [ -e /home/staging/capistrano/current/tmp/pids/unicorn.pid ]; then\\\n              if sudo -p 'sudo password: ' -u staging kill -0 `cat /home/staging/capistrano/current/tmp/pids/unicorn.pid` > /dev/null 2>&1; then\\\n                echo \"Unicorn is already running!\";\\\n                exit 0;\\\n              fi;\\\n\\\n              sudo -p 'sudo password: ' -u staging rm /home/staging/capistrano/current/tmp/pids/unicorn.pid;\\\n            fi;\\\n\\\n            echo \"Starting Unicorn...\";\\\n            cd /home/staging/capistrano/current && sudo -p 'sudo password: ' -u staging BUNDLE_GEMFILE=/home/staging/capistrano/current/Gemfile bundle exec unicorn -c $UNICORN_CONFIG_PATH -E staging -D;"
servers: ["ccdev.dyndns.org"]
Password:
[ccdev.dyndns.org] executing command
 ** [out :: ccdev.dyndns.org] Starting Unicorn...
 ** [out :: ccdev.dyndns.org] sudo: bundle: command not found
    command finished in 785ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'default' -c 'if [ -e /home/staging/capistrano/current/config/unicorn.rb ]; then\\\n              UNICORN_CONFIG_PATH=/home/staging/capistrano/current/config/unicorn.rb;\\\n            else\\\n              if [ -e /home/staging/capistrano/current/config/unicorn/staging.rb ]; then\\\n                UNICORN_CONFIG_PATH=/home/staging/capistrano/current/config/unicorn/staging.rb;\\\n              else\\\n                echo \"Config file for \"staging\" environment was not found at either \"/home/staging/capistrano/current/config/unicorn.rb\" or \"/home/staging/capistrano/current/config/unicorn/staging.rb\"\";\\\n                exit 1;\\\n              fi;\\\n            fi;\\\n\\\n            if [ -e /home/staging/capistrano/current/tmp/pids/unicorn.pid ]; then\\\n              if sudo -p '\\''sudo password: '\\'' -u staging kill -0 `cat /home/staging/capistrano/current/tmp/pids/unicorn.pid` > /dev/null 2>&1; then\\\n                echo \"Unicorn is already running!\";\\\n                exit 0;\\\n              fi;\\\n\\\n              sudo -p '\\''sudo password: '\\'' -u staging rm /home/staging/capistrano/current/tmp/pids/unicorn.pid;\\\n            fi;\\\n\\\n            echo \"Starting Unicorn...\";\\\n            cd /home/staging/capistrano/current && sudo -p '\\''sudo password: '\\'' -u staging BUNDLE_GEMFILE=/home/staging/capistrano/current/Gemfile bundle exec unicorn -c $UNICORN_CONFIG_PATH -E staging -D;'" on ccdev.dyndns.org

I'm trying not to use sudo or rvmsudo. I've set unicorn_user = 'staging' in unicorn.rb. That's the same user as :user in deploy.rb but I was getting a can't find user for apps error till I inserted that.

Ideas?

Refactored code doesn't work with multiple servers

As far as I can tell, changing lines like

run "#{try_sudo} kill -s QUIT `cat #{unicorn_pid}`"

to

pid = unicorn_get_pid
unicorn_send_signal(pid, "QUIT")

doesn't work with multiple servers. The problem is that unicorn_get_pid uses Capistrano capture which only runs on the first matching node. The result is that the PID from the first server is used to run the 'kill' command on all other servers.

I've looked into using the Capistrano parallel to try and solve this but was not able figure out a way to capture output easily.

Cannot figure out multistage environment, unicorn_rails and -E flag

I've been using this gem for a while (awesome - thanks!) and just took the dive to try deploying an actual staging environment to my staging server, and I ran into issues. Unicorn starts with the command unicorn_rails and -E production despite all the settings being correct afaik.

This may be something unique to my machine, so asking on stack overflow as well: http://stackoverflow.com/questions/18902002/capistrano-uniocorn-gem-multistage-environment-defaulting-to-unicorn-rails-and

I noticed in deploy.rb that my unicorn_bin variable was set as unicorn_rails. I took out this setting in my deploy.rb. However unicorn:duplicate still executes the unicorn_rails command, when the default should be unicorn.

My vars are all set to staging in the deploy/staging.rb, as outlined in the multistage setup wiki document, but I noticed -E is still getting set to production.

Relevent info:

Here's my output from my unicorn.log file after a deploy:

executing ["/var/www/apps/myapp/shared/bundle/ruby/2.0.0/bin/unicorn_rails", "-c",
"/var/www/apps/myapp/current/config/unicorn.rb", "-E", "production", "-D",
{12=>#<Kgio::UNIXServer:/tmp/myapp.socket>, 13=>#<Kgio::TCPServer:fd 13>}] (in /var/www/apps/myapp/current)

Here's the output from cap unicorn:show_vars (defaults to staging)

# Environments
rails_env "staging"
unicorn_env "staging"
unicorn_rack_env "staging"

# Execution
unicorn_user nil
unicorn_bundle "/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/bundle"
unicorn_bin "unicorn"
unicorn_options "" unicorn_restart_sleep_time 2`

# Relative paths
app_subdir ""
unicorn_config_rel_path "config"
unicorn_config_filename "unicorn.rb"
unicorn_config_rel_file_path "config/unicorn.rb"
unicorn_config_stage_rel_file_path "config/unicorn/staging.rb"

# Absolute paths
app_path "/var/www/apps/myapp/current"
unicorn_pid "/var/www/apps/myapp/shared/pids/unicorn.myapp.pid"
bundle_gemfile "/var/www/apps/myapp/current/Gemfile"
unicorn_config_path "/var/www/apps/myapp/current/config"
unicorn_config_file_path "/var/www/apps/myapp/current/config/unicorn.rb"
unicorn_config_stage_file_path
-> "/var/www/apps/myapp/current/config/unicorn/staging.rb"

And another curiousity, the unicorn_rails -E flag should reference the rails environment, whereas the unicorn -E should reference the rack env -- the rack env should only get the values developement and deployment, but it gets set to production, which is a bit strange.

Any insight into this would be much appreciated. On my staging server, I've also set the RAILS_ENV to staging. I've set up the things for rails for another environment, like adding staging.rb in my environments folder, adding a staging section to database.yml, etc.

important lines in lib/capistrano-unicorn/config.rb talking about unicorn_rack_env:

_cset(:unicorn_env) { fetch(:rails_env, 'production' ) } _cset(:unicorn_rack_env) do fetch(:rails_env) == 'development' ? 'development' : 'deployment' end
(references Following recommendations from http://unicorn.bogomips.org/unicorn_1.html)
Thanks in advance.

unicorn:reload sometimes doesn't kill the old pid

I'm having a problem where unicorn:reload is giving me two live unicorn instances (sometimes of different versions!)

I'm sure the base cause for this is a bug in unicorn regarding the USR2 signal... however, I'd love if there were a config option to expand unicorn:reload to unicorn:stop+unicorn:start for verbosity's sake.

Unfortunately, either way means I won't be updating my on the fly without downtime.

unicorn:reload not starting a down unicorn

hello,

I have been doing some testing and when unicorn is not running, running cap deploy it doesnt start properly. I have been trying to debug but for some reason, when 3 of the 4 nodes are running and 1 node is not, it just drops into sending a USR2 and the node that is down just throws an error about "missing pid, unable to Kill -USR2"

Is there a way to properly start the unicorn if its not running in unicorn:reload as part of after deploy:restart ?

Must Restart twice to see the latest codes deployed

Hi,

I use capistrano unicorn:legacy_restart, when I update the codes, I have to call the following twice to see the codes take effect.

How to restart once and see the codes update

 bundle exec cap production unicorn:legacy_restart 

start unicorn_rails (instead of unicorn)

Thanks for providing this.

It works great for Rack-Apps.

Unfortunately I've to deploy a Rails 2.3-App using unicorn_rails but I can not configure the unicorn binary.

Would be nice if we can swap
bundle exec unicorn
by
bundle exec unicorn_rails
or
bin/unicorn_rails
or
bin/unicorn

(for using rbenv / binstubs...
bundle -v
Bundler version 1.1.rc.7
bundle install --binstubs --shebang ruby-local-exec)

`rails_env` / `unicorn_env` / `app_env` are redundant or undocumented

It's not at all clear why we need three variables which apparently serve the same purpose:

  • rails_env
  • unicorn_env
  • app_env

If they are really all necessary and serve different purposes then they should be documented properly. Otherwise they should be collapsed to just one variable, or two at most (since I can just about imagine that someone might want unicorn_env to have a different value to rails_env).

problem while deploying with capistrano-unicorn

Hi,

since today I have some issue when I try to stop / start / restart unicorn
I can't understand why but it seems to be mixing my local user and my server user

on config/unicorn/production.rb I have
user 'userserver', 'userserver'

where 'userserver' is the name of the user on server
so when I launch command cap unicorn:restart
I have error u can see here https://gist.github.com/optimum-dulopin/7109877

If I simply change

user 'userserver', 'userserver'

by

user 'userlocal', 'userlocal'

where 'userlocal' is the name of the user my personnal computer, then it is working !

do I do something wrong ? I thought that the user in this file should be the on server, not on local machine.
moreover it was working fine the 6 last month !

thanks

`unicorn master (old)` hanging around

When doing a cap deploy the old master still hangs around.

See SIGNALS in the unicorn docs. There should be a task or something to kill off the old master or roll back to old master and kill the new one.

Ciao!

huge number of unmerged forks

I just looked at the github network graph and was disappointed to see a huge number of forks with unmerged patches, mostly without corresponding pull requests. Everybody loses out badly through this fragmentation, so it should be discouraged.

Suggested actions:

  • update the README to ask people to submit pull requests
  • add comments to commits in forked repositories asking the author to submit a pull request
  • proactively merge from forks back into this repo
  • make a new release

Thanks for listening!

assets:precomplie bug in v0.1.10 - Namespaces#to_s

I found that my assets are not updated.

The log shows that it's executing the command

RAILS_ENV=production RAILS_GROUPS=assets #<Capistrano::Configuration::Namespaces::Namespace:0x007fe395170a90> assets:precompile

Clearly the Namespace object's to_s method is broken.

README and NEWS files seem to be ahead of actual release

According to rubygems and the list of github tags, version 0.2.0 isn't actually released yet, but the NEWS file lists it as released, and the README documents the unicorn:show_vars task which apparently doesn't exist before the 0.2.0 branch. Is there any chance the 0.2.0 branch can be released soon, to bring it into line with what's documented here? Thanks!

v0.2.0 failed to restart unicon due to incorrect pid file path

I noticed that this gem failed to restart unicorn after I upgraded to v0.2.0, due to the missing of app_path.

0.2.0

executing "if [ -e tmp/pids/unicorn.pid ] &&  kill -0 `cat tmp/pids/unicorn.pid` >

0.1.10

executing "if [ -e /u/apps/avcloud/current/tmp/pids/unicorn.pid ] &&  kill -0 `cat /u/apps/avcloud/current/tmp/pids/unicor

I'm using a multistage cap. Not sure if that's related.

It happens on unicorn:stop, restart etc.

avoiding duplicate unicorns starting with Upstart / Init

Hey all,

I was getting two errors that bugged me for a while: my environment variable was being overwritten and I couldn't figure out how to set it within my deploy scripts (e.g. staging and production), and my unicorn process, after unicorn:duplicate, was running into an error and not being able to listen on the appropriate ports. I had to manually send a kill -QUIT to pidfile.oldbin after each deploy to start my new unicorn.

I finally figured out that my init scripts were starting unicorn during the unicorn:duplicate process, and my init scripts had a different environment specified than my deploy.rb.

Here's my setup (in a gist) to handle capistrano-unicorn with monit / upstart / init scripts: https://gist.github.com/danman01/8640750

I was thinking of adding this as a wiki entry as a warning to those who use these scripts (which I would imagine is nearly everyone), but want to verify this is a good enough solution for the wiki (there's nothing over there now - should it be a place for tips & best practices?)

Does anyone have experience running Monit with init / upstart and capistrano-unicorn all in perfect unison? Could you perhaps share your solution with me and we could create a wiki entry for others?

Thanks

Usage examples

Need more examples. Since there are a lot of ways on how to use capistrano-unicorn there should be a directory with detailed examples. Current rails example is also not correct.

Planned examples:

  • Rails 3.1.x/3.2.x
  • Sinatra
  • Preloaded / not preloaded applications

config.eager_load is set to nil

I'm attempting to run bundle exec unicorn -c /var/www/skateboxes/current/config/unicorn/production.rb -E deployment which is what cap production unicorn:start runs. I get the following output:

INFO -- : Refreshing Gem list
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:

  * development - set it to false
  * test - set it to false (unless you use a tool that preloads your test environment)
  * production - set it to true

I, [2013-10-25T00:57:12.607520 #7233]  INFO -- : unlinking existing socket=/tmp/unicorn.skateboxes.sock
I, [2013-10-25T00:57:12.607950 #7233]  INFO -- : listening on addr=/tmp/unicorn.skateboxes.sock fd=10
E, [2013-10-25T00:57:12.851888 #7233] ERROR -- : database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/connection_specification.rb:52:in `resolve_hash_connection'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/connection_specification.rb:30:in `spec'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_handling.rb:39:in `establish_connection'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railtie.rb:175:in `block (2 levels) in <class:Railtie>'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/base.rb:322:in `<module:ActiveRecord>'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/base.rb:22:in `<top (required)>'
/var/www/skateboxes/current/config/unicorn/production.rb:28:in `block in reload'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:495:in `call'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:495:in `spawn_missing_workers'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:142:in `start'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/bin/unicorn:126:in `<top (required)>'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
/var/www/skateboxes/shared/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'

My production config definitely has this set to true. I fee like this has something to do w/ the -E flag. If I sent this to production then the error disappears and my app starts.

Using with Rainbows!

Not an issue at all, rather a question.

I presume it is easily possible to use capistrno-unicorn with rainbows.

All that's really necessary is to change the unicorn_bin to "rainbows".

I'm not sure how much true it is, but I presume it indeed is since Rainbows extends unicorn and all the start/stop/restart stuff is still the same.

Would be much appreciated if someone could confirm or comment on this.

Remind the developer to use absolute path if Unicorn sockets is been used.

I was having issue to have cap deploy to restart unicorn for a preload_app. The duplicated unicorn will fail do bind the socket.

I found that the problem is gone if I used absolute path in config/unicorn.rb.

app_path = "/u/apps/radiant_land/current"
listen "unix:#{app_path}/tmp/sockets/unicorn.sock"

It think it's due to how capistrano re-create the app folder and symbol links. Please make a note of this on the config file.

Bellow is the error if using relative socket path and try to cap deploy when unicorn is already running. Note that it only happens with cap deploy not cap unicorn:restart as only the former would recreate the folders and links.

I, [2013-08-09T06:31:57.554755 #12707]  INFO -- : listening on addr=/u/apps/radiant_land/releases/20130809132821/tmp/sockets/unicorn.sock fd=11
I, [2013-08-09T06:31:57.564837 #12707]  INFO -- : master process ready
I, [2013-08-09T06:31:57.567537 #12728]  INFO -- : worker=0 ready
I, [2013-08-09T06:31:57.568356 #12731]  INFO -- : worker=1 ready
I, [2013-08-09T06:33:49.251529 #15352]  INFO -- : executing ["/u/apps/radiant_land/shared/bundle/ruby/2.0.0/bin/unicorn", "-c", "/u/apps/radian
t_land/current/config/unicorn.rb", "-E", "production", "-D", {11=>#<Kgio::UNIXServer:/u/apps/radiant_land/releases/20130809132821/tmp/sockets/u
nicorn.sock>}] (in /u/apps/radiant_land/releases/20130809133015)
I, [2013-08-09T06:33:49.251727 #15352]  INFO -- : forked child re-executing...
I, [2013-08-09T06:33:49.535625 #15352]  INFO -- : inherited addr=/u/apps/radiant_land/releases/20130809132821/tmp/sockets/unicorn.sock fd=11
I, [2013-08-09T06:33:49.535997 #15352]  INFO -- : Refreshing Gem list
E, [2013-08-09T06:33:51.078553 #15352] ERROR -- : adding listener failed addr=/u/apps/radiant_land/releases/20130809133015/tmp/sockets/unicorn.
sock (in use)
E, [2013-08-09T06:33:51.078635 #15352] ERROR -- : retrying in 5 seconds (4 tries left)
I, [2013-08-09T06:33:54.347957 #12707]  INFO -- : reaped #<Process::Status: pid 12728 exit 0> worker=0
I, [2013-08-09T06:33:54.348174 #12707]  INFO -- : reaped #<Process::Status: pid 12731 exit 0> worker=1
I, [2013-08-09T06:33:54.348223 #12707]  INFO -- : master complete
E, [2013-08-09T06:33:56.079288 #15352] ERROR -- : adding listener failed addr=/u/apps/radiant_land/releases/20130809133015/tmp/sockets/unicorn.
sock (in use)
E, [2013-08-09T06:33:56.079403 #15352] ERROR -- : retrying in 5 seconds (3 tries left)
E, [2013-08-09T06:34:01.080030 #15352] ERROR -- : adding listener failed addr=/u/apps/radiant_land/releases/20130809133015/tmp/sockets/unicorn.
sock (in use)
E, [2013-08-09T06:34:01.080134 #15352] ERROR -- : retrying in 5 seconds (2 tries left)
E, [2013-08-09T06:34:06.080857 #15352] ERROR -- : adding listener failed addr=/u/apps/radiant_land/releases/20130809133015/tmp/sockets/unicorn.
sock (in use)
E, [2013-08-09T06:34:06.080965 #15352] ERROR -- : retrying in 5 seconds (1 tries left)
E, [2013-08-09T06:34:11.081692 #15352] ERROR -- : adding listener failed addr=/u/apps/radiant_land/releases/20130809133015/tmp/sockets/unicorn.
sock (in use)
E, [2013-08-09T06:34:11.081791 #15352] ERROR -- : retrying in 5 seconds (0 tries left)
E, [2013-08-09T06:34:16.082448 #15352] ERROR -- : adding listener failed addr=/u/apps/radiant_land/releases/20130809133015/tmp/sockets/unicorn.
sock (in use)
/u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:140:in `initialize': Address already in use - "/u
/apps/radiant_land/releases/20130809133015/tmp/sockets/unicorn.sock" (Errno::EADDRINUSE)
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:140:in `new'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:140:in `bind_listen'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:229:in `listen'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:773:in `block in bind_new_listeners!'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:773:in `each'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:773:in `bind_new_listeners!'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:141:in `start'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/gems/unicorn-4.6.3/bin/unicorn:126:in `<top (required)>'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
        from /u/apps/radiant_land/shared/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'
I, [2013-08-09T06:38:12.150644 #21693]  INFO -- : Refreshing Gem list

Easy Questions

Hey, this is a really great gem. So first and foremost, thanks so much for that. I have a few simple questions.

  1. If I want to use monit to monitor the unicorn workers outside of the deploy hook, is there a way monit can use capistrano-unicorn for starting/stopping/restarting, so I dont need to use that unicorn_init shell script?
  2. I have read about pre-loading but sadly I can't find what it's actually for. The most I can gather that it's for zero downtime deployments, and that I should be very careful if I'm using a socket (which I am).
  3. Does that before/after hook still apply to rails 4?

Thanks!

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec,

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Even for projects that already specify a license, including a license in your gemspec is a good practice, since it is easily
discoverable there without having to check the readme or for a license file. For example, it is the field that rubygems.org uses to display a gem's license.

For example, there is a License Finder gem to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough
issue that even Bundler now generates gems with a default 'MIT' license.

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), github has created a license picker tool.

In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :).

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue and let me know. In either case, I'll follow up. Thanks!

p.s. I've written a blog post about this project

Unicron Starting Cause ActiveRecord::AdapterNotSpecified Specified error

Here is my unicorn.rb code

app_path = "/home/deploy/apps/local.myapp.com/myapp/current"

# Set unicorn options
worker_processes 1
preload_app true
timeout 180

listen "#{app_path}/tmp/pids/unicorn.sock", backlog: 1024
pid    "#{app_path}/tmp/pids/unicorn.pid"

# Spawn unicorn master worker for user apps (group: apps)

# Fill path to your app
working_directory app_path

# Should be 'production' by default, otherwise use other env 
rails_env = 'local'

# Log everything to one file
stderr_path "log/unicorn.log"
stdout_path "log/unicorn.log"

before_fork do |server, worker|
  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
      # someone else did our job for us
    end
  end
end

after_fork do |server, worker|
  ActiveRecord::Base.establish_connection
end

When I use capistrano command cap local unicorn:start it cause this error:

/home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection': current database is not configured (ActiveRecord::AdapterNotSpecified)
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/railtie.rb:59:in `block (2 levels) in <class:Railtie>'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.0.3/lib/active_record/railtie.rb:57:in `block in <class:Railtie>'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
    from /home/deploy/apps/local.myapp.com/myapp/shared/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
    from /home/deploy/apps/local.myapp.com/myapp/releases/20121110235022/config/environment.rb:8:in `<top (required)>'

Where as if I run this command from bash console on the server it works pretty fine.

 BUNDLE_GEMFILE=/home/deploy/apps/local.myapp.com/myapp/current/Gemfile bundle exec unicorn -c /home/deploy/apps/local.myapp.com/myapp/current/config/unicorn/local.rb -E local -D

Due to this issue my deployment process is struck. Please look into this issue and guide me.

Update README

Readme needs some cleanup and more detailed usage instructions.

unicorn:restart sends QUIT to old master before new master's workers are up

First, thanks for the lib, this is pretty handy. Just a quick question. I saw this pull request merged in that I think added this behavior.

#26

And in the sample unicorn file here there is also a QUIT sent to the old master:

https://github.com/sosedoff/capistrano-unicorn/blob/master/examples/rails3.rb

When I run cap unicorn:restart the task properly sends the USR2 to the old master, sleeps 2 seconds, then sends a QUIT to the old master. At this point, the workers of the new master are not yet up, so there are no workers left to handle the request, and web browsers that had started a request sit idly by. If one of the useful things of Unicorn is to have no downtime for handling requests, why is this the behavior? I'm a bit new to Unicorn as well, so please let me know if I have the wrong expectation here. Thanks.

New release

The recent gem is not based on the newest source.

Would be great if you could release a new gem version.

Detecting failed restart

Hi,

I have a problem which I assume many people have: Sometimes, when restarting Unicorn on deploy, due to bad code, it fails to restart and stays with old code running.

Is there any way to hook on a failed restart and deliver a notification about that?

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.