Browse Source

Readme updated, some tweaks around unicorn_rails and a small user bugfix

master
Erik Hollensbe 10 years ago
parent
commit
f679fa6cfb
  1. 25
      README.md
  2. 12
      files/default/unicorn_rack.sh
  3. 2
      recipes/default.rb

25
README.md

@ -17,21 +17,13 @@ The script itself takes two arguments: the directive (stop, start, restart,
reload) and the name of the app. **If the name of the app is omitted all apps
will recieve the actions taken for the directive.**
databags and the `unicorn.json` file
databags and the `unicorn.conf` file
--------------------------------------------------------------------------------
The `unicorn.json` file is generated by the recipe, and looks a bit like this:
The `/etc/unicorn.conf` file is generated by the recipe, and looks a bit like this:
{
"/www/stuff": {
"config_path": "/www/stuff/config/unicorn.rb",
"bin": "unicorn_rails"
},
"/www/jsonip": {
"config_path": "/www/jsonip/config/unicorn.rb",
"bin": "unicorn"
}
}
/www/chef-dashboard:/www/chef-dashboard/config/unicorn.rb:unicorn:rails
/www/jsonip:/www/jsonip/config/unicorn.rb:unicorn:rails
The key is the path to the application, it will be started from that directory.
@ -51,12 +43,15 @@ Where `hosts` is an array of node names, and the path is the key of the data
structure above. Note that node configuration looks exactly the same and the
key for the node and the databag name searched are both `applications`.
**NOTE**: For those of you using the older cookbook with the `unicorn.json`
file, this will be removed on the next run after this cookbook is uploaded and
replaced by the `/etc/unicorn.conf` file.
User accounts (aka BUGS)
--------------------------------------------------------------------------------
Currently the recipes expect a `rails` user and group to exist. **It does not
create it**. This will be rectified in the future, and the author is happy to
accept pull requests that do so.
The recipes expect a `rails` user and group to exist. **It creates it for
you**.
Contributing
--------------------------------------------------------------------------------

12
files/default/unicorn_rack.sh

@ -1,5 +1,7 @@
#!/bin/bash
set -e
CONFIG_PATHS=$(awk -F: '{ print $2 }' /etc/unicorn.conf)
CONFIG=$(cat /etc/unicorn.conf)
@ -9,9 +11,7 @@ start_app() {
local bin=$3
local user=$4
cd $path
sudo -iu $user bundle exec "${bin}" -c "${config_path}" -E production -D
cd $OLDPWD
sudo -iu $user sh -c "cd ${path}; bundle exec "${bin}" -c "${config_path}" -E production -D"
}
case "$1" in
@ -23,10 +23,10 @@ case "$1" in
reload)
for path in ${CONFIG_PATHS}
do
pkill -USR2 -f "unicorn master.*${path}"
pkill -USR2 -f "unicorn(_rails)? master.*${path}"
echo "Waiting for new unicorns..."
sleep 5
pkill -QUIT -f "unicorn master \\(old\\).*${path}"
pkill -QUIT -f "unicorn(_rails)? master \\(old\\).*${path}"
done
;;
@ -57,7 +57,7 @@ case "$1" in
for path in ${CONFIG_PATHS}
do
echo "Killing ${path} with INT signal"
pkill -INT -f "unicorn master.*${path}"
pkill -INT -f "unicorn(_rails)? master.*${path}"
done
;;
esac

2
recipes/default.rb

@ -1,7 +1,7 @@
require 'yajl'
user 'rails' do
shell "/bin/false"
shell "/bin/bash"
action :create
end

Loading…
Cancel
Save