Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capistrano-unicorn with capistrano 3.x #82

Open
sepastian opened this issue Oct 22, 2013 · 17 comments
Open

capistrano-unicorn with capistrano 3.x #82

sepastian opened this issue Oct 22, 2013 · 17 comments

Comments

@sepastian
Copy link

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 Add a task to load defaults 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?

@jloosfelt
Copy link

Hey @sepastian, what you did is wonderful, you are in the perfect timing for me.
Except that it does not work (yet) here but maybe my config is wrong somewhere

https://gist.github.com/jloosfelt/7106348

@sepastian
Copy link
Author

Hi @jloosfelt, thanks for trying. Obviously, this is still at a very early stage and I am still quite new to Capistrano myself. I think I forgot to update the syntax for on roles in some places, just fixed that. Could you try again?

See sepastian@ef20bc2

@jloosfelt
Copy link

still not working, I've updated my gist
https://gist.github.com/jloosfelt/7106348

@kyledecot
Copy link

@sepastian I'm attempting to use your forked version but I've run into an issue. I was going to submit an issue for it but it appears that you don't have issues turned on for your project.

@sepastian
Copy link
Author

Please try again, @kyledecot, issues should be turned on now.

@inbeom
Copy link

inbeom commented Nov 12, 2013

@jloosfelt @kyledecot, how about using my fork? I've run it without errors on my environment.

https://github.com/inbeom/capistrano-unicorn/tree/capistrano3

@emoreth
Copy link

emoreth commented Nov 28, 2013

@inbeom version worked for me as well. But not @sepastian T.T

@umhan35
Copy link

umhan35 commented Dec 19, 2013

I used @inbeom fork. I have the following code to make it work: set :unicorn_rack_env, :production in deploy/production.rb and set :unicorn_bin, 'unicorn_rails' in deploy.rb

Here is the code in Gemfil dev group: gem 'capistrano-unicorn', require: false, github: 'inbeom/capistrano-unicorn', branch: 'capistrano3'

@tomafc330
Copy link

I can't seem to have capistrano see the tasks after I did what @umhan35 above:

tcc@venuespot-beta:~/ba$ bundle exec cap -T
cap bundler:install                # Install the current Bundler environment
cap deploy                         # Deploy a new release
cap deploy:check                   # Check required files and directories exist
cap deploy:check:directories       # Check shared and release directories exist
cap deploy:check:linked_dirs       # Check directories to be linked exist in shared
cap deploy:check:linked_files      # Check files to be linked exist in shared
cap deploy:check:make_linked_dirs  # Check directories of files to be linked exist in shared
cap deploy:cleanup                 # Clean up old releases
cap deploy:cleanup_assets          # Cleanup expired assets
cap deploy:cleanup_rollback        # Remove and archive rolled-back release
cap deploy:compile_assets          # Compile assets
cap deploy:finished                # Finished
cap deploy:finishing               # Finish the deployment, clean up server(s)
cap deploy:finishing_rollback      # Finish the rollback, clean up server(s)
cap deploy:log_revision            # Log details of the deploy
cap deploy:migrate                 # Runs rake db:migrate if migrations are set
cap deploy:normalise_assets        # Normalise asset timestamps
cap deploy:published               # Published
cap deploy:publishing              # Publish the release
cap deploy:revert_release          # Revert to previous release timestamp
cap deploy:reverted                # Reverted
cap deploy:reverting               # Revert server(s) to previous release
cap deploy:rollback                # Rollback to previous release
cap deploy:rollback_assets         # Rollback assets
cap deploy:started                 # Started
cap deploy:starting                # Start a deployment, make sure server(s) ready
cap deploy:symlink:linked_dirs     # Symlink linked directories
cap deploy:symlink:linked_files    # Symlink linked files
cap deploy:symlink:release         # Symlink release to current
cap deploy:symlink:shared          # Symlink files and directories from shared to release
cap deploy:updated                 # Updated
cap deploy:updating                # Update server(s) by setting up a new release
cap install                        # Install Capistrano, cap install STAGES=staging,production
cap sidekiq:quiet                  # Quiet sidekiq (stop accepting new work)
cap sidekiq:restart                # Restart sidekiq
cap sidekiq:start                  # Start sidekiq
cap sidekiq:stop                   # Stop sidekiq
tcc@venuespot-beta:~/venuespot$ 

Any suggestions?

@shardnit
Copy link

shardnit commented Jan 7, 2014

@tommytcchan do you have following in your project's Capfile?

require 'capistrano/unicorn'

@umhan35
Copy link

umhan35 commented Jan 7, 2014

@tommytcchan also the after deploy:restart hook

@tomafc330
Copy link

@nsa310 Thanks you're right.. I had require 'capistrano-unicorn instead of require capistrano/unicorn from the previous version. @umhan35 thanks

@tomafc330
Copy link

Just an FYI, it seems that both unicorn_env and unicorn_rack_env vars have to be set if it's deploying to something other than production.

unicorn_env        beta
unicorn_rack_env   beta

@pmontrasio
Copy link

I managed to make cap -T show the tasks with

Gemfile:

gem 'capistrano-unicorn', require: false, github: 'inbeom/capistrano-unicorn', branch: 'capistrano3'

Capfile:

require 'capistrano/unicorn'

If I use this repository and require 'capistrano-unicorn' I get

$ bundle exec cap -T 
cap aborted!
undefined method `instance' for Capistrano::Configuration:Class
~/.rvm/gems/ruby-2.1.0@xyz/gems/capistrano-unicorn-0.1.10/lib/capistrano-unicorn/capistrano_integration.rb:224:in `<top (required)>'
~/.rvm/gems/ruby-2.1.0@xyz/gems/capistrano-unicorn-0.1.10/lib/capistrano-unicorn.rb:2:in `require'
~/.rvm/gems/ruby-2.1.0@xyz/gems/capistrano-unicorn-0.1.10/lib/capistrano-unicorn.rb:2:in `<top (required)>'
...

By the way, @inbeom please fix the README of the capistrano3 branch because it says

And load it into your deployment script config/deploy.rb:
require 'capistrano-unicorn'

Wrong file and wrong require.
I write it here because this is where google seems to direct people looking for the gem and it might be more useful here than there.

@asanger
Copy link

asanger commented Jan 15, 2014

Interesting. Using the forked repo from above, I run into an error saying that it can't load 'capistrano-unicorn'. Is this now working properly for you?

@pmontrasio
Copy link

It works with the settings at the top of my comment. The big difference between @inbeom 's repository and this one is that for the former we must require capistrano/unicorn and not capistrano-unicorn.
With that the tasks show up in cap -T

That said, I can't make them do any useful work. Example: cap production unicorn:start (or stop) hangs on

Command: kill -0 `cat ` > /dev/null 2>&1

which probably means that there is a shell variable evaluated to an empty string, but that's a different story and worth of a different issue if I can understand what's going on.

@DavidBennettPIO
Copy link

just as a note, I have been using this with capistrano 3.1

https://github.com/tablexi/capistrano3-unicorn

Working well for me so far :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests