mina-unicorn 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3060caa6683521e9cdbb43ee4edccc0876895660
4
- data.tar.gz: a7812f1216d64276354f93b84fc383b7b7d3f8d6
3
+ metadata.gz: 78c8bbb22a35b3620cf8239a7c28ffde5564f5da
4
+ data.tar.gz: ef723c4beef647a3e4a03025b479cabe0219bef3
5
5
  SHA512:
6
- metadata.gz: a4a2037d08240024a3c652bae17770eb4ada82841d92c714260a482d30d825d3fce57a11aa96fe48d8264cee09035cdbda1fa0cf99ea7302d63955e2c1dfed81
7
- data.tar.gz: 340dc91ac2f776c8d3c7a329cfb1718593ac5255fa98fadd9a8cca02485431dc791a5b0a8eb818e8c9ae540414bcf0f0895d9d074fe8cc8df22ce51c800f96fd
6
+ metadata.gz: d960e7a0a5980d8b06b3b98edf02fd748547ede5e9fb507163e0b207ee30e12fab19bb76bfb118dd72665c0d8e05044bb7e9eb6c6655ec1bfabd2ae9481f05b1
7
+ data.tar.gz: fc35beaca49cd0387e96bb661226268a5d83f354af8a1e76611656c88a320c72a62d2e4f8f70e901579ab63decb987877501b5c61618b054236e2c19e512d314
data/README.md CHANGED
@@ -38,9 +38,10 @@ set :shared_paths, ['tmp/sockets', 'tmp/pids']
38
38
  You can also set individual config variables to override default values for
39
39
  unicorn:
40
40
 
41
- * `unicorn_env` - set environment, default: depending on `rails_env`: `development` or `deployment` (see: [Rack environment](http://unicorn.bogomips.org/unicorn_1.html#rack-environment))
41
+ * `unicorn_env` - set unicorn environment, default: depending on `rails_env`: `development` or `deployment` (see: [Rack environment](http://unicorn.bogomips.org/unicorn_1.html#rack-environment))
42
+ * `rails_env` - set rails environment, default: `production`
42
43
  * `unicorn_config` - unicorn config file, default: `config/unicorn.rb`
43
- * `unicorn_cmd` - bundle exec unicorn, default: `bundle exec unicorn`
44
+ * `unicorn_cmd` - bundle exec unicorn, default: `RAILS_ENV=production bundle exec unicorn` (see: [mina/rails](https://github.com/mina-deploy/mina/blob/master/lib%2Fmina%2Frails.rb#L25))
44
45
  * `unicorn_pid` - unicorn pid file, default: `tmp/pids/unicorn.pid`
45
46
 
46
47
  Then:
@@ -4,10 +4,17 @@ module Mina
4
4
  module Unicorn
5
5
  module Utility
6
6
 
7
+ # Run a command as the :unicorn_user user if :unicorn_user is a string.
8
+ # Otherwise run as default (:user) user.
9
+ #
10
+ def try_unicorn_user
11
+ "sudo -u #{unicorn_user}" if unicorn_user.kind_of?(String)
12
+ end
13
+
7
14
  # Check if a remote process exists using its pid file
8
15
  #
9
16
  def remote_process_exists?(pid_file)
10
- "[ -e #{pid_file} ] && kill -0 `cat #{pid_file}` > /dev/null 2>&1"
17
+ "[ -e #{pid_file} ] && #{try_unicorn_user} kill -0 `cat #{pid_file}` > /dev/null 2>&1"
11
18
  end
12
19
 
13
20
  # Stale Unicorn process pid file
@@ -43,7 +50,7 @@ module Mina
43
50
  # Send a signal to a unicorn master processes
44
51
  #
45
52
  def unicorn_send_signal(signal, pid=get_unicorn_pid)
46
- "kill -s #{signal} #{pid}"
53
+ "#{try_unicorn_user} kill -s #{signal} #{pid}"
47
54
  end
48
55
 
49
56
  # Kill Unicorns in multiple ways O_O
@@ -66,16 +73,16 @@ module Mina
66
73
  def start_unicorn
67
74
  %Q%
68
75
  if [ -e "#{unicorn_pid}" ]; then
69
- if kill -0 `cat #{unicorn_pid}` > /dev/null 2>&1; then
76
+ if #{try_unicorn_user} kill -0 `cat #{unicorn_pid}` > /dev/null 2>&1; then
70
77
  echo "-----> Unicorn is already running!";
71
78
  exit 0;
72
79
  fi;
73
80
 
74
- rm #{unicorn_pid};
81
+ #{try_unicorn_user} rm #{unicorn_pid};
75
82
  fi;
76
83
 
77
84
  echo "-----> Starting Unicorn...";
78
- cd #{deploy_to}/#{current_path} && BUNDLE_GEMFILE=#{bundle_gemfile} #{unicorn_cmd} -c #{unicorn_config} -E #{unicorn_env} -D;
85
+ cd #{deploy_to}/#{current_path} && #{try_unicorn_user} BUNDLE_GEMFILE=#{bundle_gemfile} #{unicorn_cmd} -c #{unicorn_config} -E #{unicorn_env} -D;
79
86
  %
80
87
  end
81
88
 
@@ -1,5 +1,5 @@
1
1
  module Mina
2
2
  module Unicorn
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina-unicorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tab
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-25 00:00:00.000000000 Z
12
+ date: 2015-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler