unicorn-ctl 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/README.md +10 -6
  3. data/bin/unicornctl +28 -4
  4. metadata +1 -1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## UnicornCtl Changelog
2
2
 
3
+ ### 0.1.2 / 2013-09-11
4
+
5
+ * Added `status` command.
6
+
3
7
  ### 0.1.1 / 2013-09-11
4
8
 
5
9
  * Added `reopen-logs` command.
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  ## unicornctl - unicorn/rainbows control script
2
2
 
3
- `unicornctl` is a simple and easy to use console tool for managing ruby applications using
4
- [unicorn](http://unicorn.bogomips.org/) or [rainbows](http://rainbows.rubyforge.org/) application servers.
5
- The tool provides a set of reliable commands to start/stop/restart unicorn instances or upgrade them
6
- without or with minimal downtime. `unicornctl` script could easily be used as a base for a startup
3
+ `unicornctl` is a simple and easy to use console tool for managing ruby applications using
4
+ [unicorn](http://unicorn.bogomips.org/) or [rainbows](http://rainbows.rubyforge.org/) application servers.
5
+ The tool provides a set of reliable commands to start/stop/restart unicorn instances or upgrade them
6
+ without or with minimal downtime. `unicornctl` script could easily be used as a base for a startup
7
7
  script for unix operating systems (see examples directory for a Redhat-style startup script example).
8
8
 
9
- Please note, that this is still an alpha-quality software and it could have many issues. If you try it and
10
- find any problems, feel free to report them using [Github Issues page](https://github.com/swiftype/unicorn-ctl/issues).
9
+ Please note, that this is still an alpha-quality software and it could have many issues. If you try it and
10
+ find any problems, feel free to report them using [Github Issues page](https://github.com/swiftype/unicorn-ctl/issues).
11
11
  Pull requests are welcome too!
12
12
 
13
13
  ### Installation
@@ -58,6 +58,10 @@ The following command are supported at the moment:
58
58
  * `upgrade` - zero or minimal downtime restart option for a unicorn application. Performs a set of
59
59
  steps to start a new copy of the application, test it and then gracefully shut down the old copy.
60
60
  If the graceful restart fails for any reason, the application is forcefully restarted.
61
+ * `reopen-logs` - Makes unicorn reopen its log files. This allows logrotate to rotate files atomically
62
+ and quickly via rename instead of the racy and slow copytruncate method.
63
+ * `status` - Display current application server status. If the server is up, the command exits with exit
64
+ code 0, otherwise the exit code will be 1.
61
65
 
62
66
  For more information on unicorn procss management you could check their
63
67
  [official documentation page](http://unicorn.bogomips.org/SIGNALS.html).
data/bin/unicornctl CHANGED
@@ -14,6 +14,7 @@ VALID_COMMANDS = %w[
14
14
  force-restart
15
15
  upgrade
16
16
  reopen-logs
17
+ status
17
18
  ]
18
19
 
19
20
  #---------------------------------------------------------------------------------------------------
@@ -169,7 +170,7 @@ def start_application!(options)
169
170
  # Done
170
171
  exit(0)
171
172
  else
172
- puts "WARNING: Slate pid file found, removing it: #{pid_file}"
173
+ puts "WARNING: Stale pid file found, removing it: #{pid_file}"
173
174
  FileUtils.rm(pid_file)
174
175
  end
175
176
  end
@@ -240,7 +241,7 @@ def stop_application!(options, graceful = false)
240
241
  if pid_running?(pid)
241
242
  stop_unicorn_process(pid, options[:timeout], graceful)
242
243
  else
243
- puts "WARNING: Slate pid file found, removing it: #{pid_file}"
244
+ puts "WARNING: Stale pid file found, removing it: #{pid_file}"
244
245
  FileUtils.rm(pid_file)
245
246
  end
246
247
 
@@ -257,7 +258,7 @@ def restart_application!(options, graceful)
257
258
  if pid_running?(pid)
258
259
  stop_unicorn_process(pid, options[:timeout], graceful)
259
260
  else
260
- puts "WARNING: Slate pid file found, removing it: #{pid_file}"
261
+ puts "WARNING: Stale pid file found, removing it: #{pid_file}"
261
262
  FileUtils.rm(pid_file)
262
263
  end
263
264
 
@@ -368,7 +369,7 @@ def reopen_logs!(options)
368
369
  puts "Sending USR1 signal to process with pid=#{pid}..."
369
370
  send_signal('USR1', pid)
370
371
  else
371
- puts "WARNING: Slate pid file found, removing it: #{pid_file}"
372
+ puts "WARNING: Stale pid file found, removing it: #{pid_file}"
372
373
  FileUtils.rm(pid_file)
373
374
  end
374
375
 
@@ -376,6 +377,26 @@ def reopen_logs!(options)
376
377
  exit(0)
377
378
  end
378
379
 
380
+ #---------------------------------------------------------------------------------------------------
381
+ def status!(options)
382
+ # Check pid file
383
+ pid_file = unicorn_pid_file(options)
384
+ unless File.exists?(pid_file)
385
+ puts "No pid file found, the app is not running"
386
+ exit(1)
387
+ end
388
+
389
+ # Check the process
390
+ pid = read_pid(pid_file)
391
+ if pid_running?(pid)
392
+ puts "The app is running, pid=#{pid}..."
393
+ exit(0)
394
+ else
395
+ puts "Stale pid file found, the app is not running"
396
+ exit(1)
397
+ end
398
+ end
399
+
379
400
  #---------------------------------------------------------------------------------------------------
380
401
  def show_help(error = nil)
381
402
  puts "ERROR: #{error}\n\n" if error
@@ -501,6 +522,9 @@ case command
501
522
  when 'reopen-logs'
502
523
  reopen_logs!(options)
503
524
 
525
+ when 'status'
526
+ status!(options)
527
+
504
528
  else
505
529
  show_help("ERROR: Invalid command: #{command}")
506
530
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn-ctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: