Coder Social home page Coder Social logo

mina-unicorn's Introduction

Mina::Unicorn

Mina tasks for handle with Unicorn

This gem provides several mina tasks:

mina unicorn:start           # Start unicorn
mina unicorn:stop            # Stop unicorn
mina unicorn:restart         # Restart unicorn (with zero-downtime)

Installation

Add this line to your application's Gemfile:

gem 'mina-unicorn', :require => false

And then execute:

$ bundle

Or install it yourself as:

$ gem install mina-unicorn

Usage

Add this to your config/deploy.rb file:

require 'mina/unicorn'

Make sure to add the following directories to :shared_paths in config/deploy.rb:

set :shared_paths, ['tmp/sockets', 'tmp/pids']

You can also set individual config variables to override default values for unicorn:

  • unicorn_env - set unicorn environment, default: depending on rails_env: development or deployment (see: Rack environment)
  • rails_env - set rails environment, default: production
  • unicorn_config - unicorn config file, default: config/unicorn.rb
  • unicorn_cmd - bundle exec unicorn, default: RAILS_ENV=production bundle exec unicorn (see: mina/rails)
  • unicorn_pid - unicorn pid file, default: tmp/pids/unicorn.pid

Then:

$ mina unicorn:start

Contributing

  1. Fork it ( http://github.com/scarfacedeb/mina-unicorn/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

mina-unicorn's People

Contributors

juanmcuello avatar ridiculous avatar scarfacedeb avatar tab avatar vicvega 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

Watchers

 avatar  avatar  avatar  avatar  avatar

mina-unicorn's Issues

Forward SECRET_KEY_BASE ?

In my config/secrets.yml:

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

And the command:

SECRET_KEY_BASE=foofoofoo mina unicorn:start

But doesn't works.
It may be a good feature, isn't it?

mina/rails should not be required

I use mina and mina-unicorn, but I don't use rails. When using mina, if you don't use rails, you simply not require mina/rails and that's it. But if you require mina/unicorn in the mina deploy.rb, mina-unicorn requires mina/rails (See this line) and you end up with with vars like shared_dirs including rails paths that aren't needed (and could create other conflicts).

I think mina-unicorn should not require mina/rails and unicorn_env, which uses rails_env should be explicitly set.

@scarfacedeb , what do you think? I can create a PR if you agree with the changes.

mina unicorn:start using wrong directory

When running unicorn start, I get the following error:

/html/dev-api/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:88:in `block in reload': directory for pid=/html/shared/tmp/pids/unicorn.pid not writable (ArgumentError)
    from /html/dev-api/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:84:in `each'
    from /html/dev-api/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:84:in `reload'
    from /html/dev-api/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:65:in `initialize'
    from /html/dev-api/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:76:in `new'
    from /html/dev-api/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:76:in `initialize'
    from /html/dev-api/current/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn:126:in `new'
    from /html/dev-api/current/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'
    from /html/dev-api/current/vendor/bundle/ruby/2.3.0/bin/unicorn:23:in `load'
    from /html/dev-api/current/vendor/bundle/ruby/2.3.0/bin/unicorn:23:in `<main>'
master failed to start, check stderr log for details

Mina is clearly getting the path to my PID file wrong:

/html/shared/tmp/pids/unicorn.pid

should be:

/html/dev-api/shared/tmp/pids/unicorn.pid

'parse_rackup_file': rackup file (config.ru) not readable (ArgumentError)

Thanks so much for this project -- much appreciated!

I'm getting the following error when trying to run unicorn:start:

'parse_rackup_file': rackup file (config.ru) not readable (ArgumentError)

Here's the backtrace:

โœ— mina unicorn:start
-----> Loading environment
-----> Loading rbenv
-----> Starting unicorn service
/home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.1/lib/unicorn/configurator.rb:659:in `parse_rackup_file': rackup file (config.ru) not readable (ArgumentError)
    from /home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.1/lib/unicorn/configurator.rb:77:in `reload'
    from /home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.1/lib/unicorn/configurator.rb:68:in `initialize'
    from /home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_server.rb:100:in `new'
    from /home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.1/lib/unicorn/http_server.rb:100:in `initialize'
    from /home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.1/bin/unicorn:126:in `new'
    from /home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/gems/unicorn-4.8.1/bin/unicorn:126:in `<top (required)>'
    from /home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'
    from /home/deployer/myapp/releases/3/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<main>'
master failed to start, check stderr log for details

Running unicorn_rails boots everything up fine.

Thanks for any help you can provide!

Supports mina 0.3.1?

Hi

I'm struggling to get this working as I've just upgraded to mina 0.3.1 from 0.3.0. Can I just confirm that mina-unicorn works with mina 0.3.1? Am using unicorn 4.8.3.

I've noticed that for 0.3.0 in railsapproot/bin there's a unicorn script, presumably generated at some point. There isn't one for mina 0.3.1 and I can't spot where this would be generated.

Thanks

"deployment" environment

How does this environment work? I've noticed it's hardcoded in your library so that Unicorn starts either as "development" or as "deployment".

How do I avoid needing a "deployment" section in all my YAML configuration files, next to "development", "test" and "production"?

Not stopping Unicorn

For some reason, the mina unicorn:stop command is not able to stop unicorn.

Starting:

Client

mina unicorn:start
-----> Loading rbenv
-----> Starting Unicorn...
Connection to 107.170.125.60 closed.
       Elapsed time: 12.51 seconds

Server

ps aux | grep 'unicorn'
johnkev+ 32389 34.2 22.0 234360 110820 ?       Sl   19:17   0:03 unicorn master -c /var/www/tire-website/current/config/unicorn.rb -E deployment -D
johnkev+ 32392  0.0 21.5 234360 107944 ?       Sl   19:17   0:00 unicorn worker[0] -c /var/www/tire-website/current/config/unicorn.rb -E deployment -D
johnkev+ 32395  0.0 21.5 234360 107940 ?       Sl   19:17   0:00 unicorn worker[1] -c /var/www/tire-website/current/config/unicorn.rb -E deployment -D
johnkev+ 32399  0.0  0.1  11740   912 pts/0    S+   19:17   0:00 grep unicorn

Stopping:

Client

mina unicorn:stop
-----> Loading rbenv
-----> Unicorn is not running.
Connection to 107.170.125.60 closed.
       Elapsed time: 10.93 seconds

Server

ps aux | grep 'unicorn'
johnkev+ 32389  4.0 22.0 234360 110820 ?       Sl   19:17   0:03 unicorn master -c /var/www/tire-website/current/config/unicorn.rb -E deployment -D
johnkev+ 32392  0.0 21.5 234360 107944 ?       Sl   19:17   0:00 unicorn worker[0] -c /var/www/tire-website/current/config/unicorn.rb -E deployment -D
johnkev+ 32395  0.0 21.5 234360 107940 ?       Sl   19:17   0:00 unicorn worker[1] -c /var/www/tire-website/current/config/unicorn.rb -E deployment -D
johnkev+ 32503  0.0  0.1  11740   916 pts/0    S+   19:18   0:00 grep unicorn

I already set shared_paths in deploy.rb: set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log', 'tmp/sockets', 'tmp/pids']. tmp/sockets and tmp/pids directories are also present in the server.

Mina, version v0.3.8
mina-unicorn (0.4.0)

Add to readme

Hello to make this wonderful app work
you need to add 'tmp/sockets', 'tmp/pids' to set :shared_paths

set :shared_paths, ['log', 'tmp/sockets', 'tmp/pids']

Maybe it could be written in the readme ?

unicorn_role setting not used

I'm deploying via user deployer, but I want my unicorn process to run under user rails. I tried changing this setting, but I then realized it's not actually being used in the code anywhere.

Unicorn not starting when using mina

When I run mina unicorn:start, I get an error: /home/deployer/xxx-api/releases/7 not found . I am certain that directory exists on the server. Can you kindly take a look to know if it is a problem with mina or mina-unicorn.

Navaratans-Mac-mini:xxx-api navtech$ RAILS_ENV=production mina unicorn:start --verbose
-----> Loading environment
$ source ~/.bashrc
-----> Loading rbenv
$ export RBENV_ROOT="$HOME/.rbenv"
$ export PATH="$HOME/.rbenv/bin:$PATH"
$ eval "$(rbenv init -)"
-----> Starting Unicorn...
/home/deployer/xxx-api/releases/7 not found
Connection to 104.131.92.185 closed.

 !     Command failed.
       Failed with status 2560

Suggestion - Restart raise error

Suggestion / question
I have added

task :deploy => :environment do
  deploy do
    invoke :'unicorn:restart'
  end
end

do you guys think uniocrn:restart should not fail if service is not yet started ?

Question

How do you use this gem from inside your deploy.rb file so that it starts either starts (if it wasnt running) or restarts unicorn when you deploy?

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.