hooves 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -0
- data/lib/hooves/unicorn.rb +45 -13
- metadata +4 -4
data/README.md
CHANGED
@@ -6,6 +6,20 @@ Install
|
|
6
6
|
--------
|
7
7
|
It's a rubygem, you'll want to include it in your Gemfile.
|
8
8
|
|
9
|
+
Usage
|
10
|
+
------
|
11
|
+
Just use `rails server`.
|
12
|
+
|
13
|
+
Config file
|
14
|
+
------------
|
15
|
+
Hooves looks for unicorn config files in two locations.
|
16
|
+
|
17
|
+
First it looks in ~/.hooves. If that file exists then it gets passed to Unicorn as the config file.
|
18
|
+
|
19
|
+
Second it looks in ./.hooves.
|
20
|
+
|
21
|
+
We look in ~/ first because you can only pass one config file to Unicorn. If your project has a .hooves file checked in to its root and you want to have a custom config file, that might be a pain. So we look in ~/ first. That might also become a pain if you want to have different configs for different projects. Let me know and we'll find something that works.
|
22
|
+
|
9
23
|
Caveats
|
10
24
|
--------
|
11
25
|
* Using this gem monkey patches Rack::Handler.default making Unicorn the default.
|
data/lib/hooves/unicorn.rb
CHANGED
@@ -5,19 +5,51 @@ require "rack/chunked"
|
|
5
5
|
module Hooves
|
6
6
|
# Rack Handler to use Unicorn for Rails::Application.run!
|
7
7
|
module Unicorn
|
8
|
-
|
9
|
-
options
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
class << self
|
9
|
+
def run(app, options={})
|
10
|
+
options[:listeners] = ["#{options.delete(:Host)}:#{options.delete(:Port)}"]
|
11
|
+
options[:worker_processes] = 3
|
12
|
+
|
13
|
+
if options.delete(:debugger)
|
14
|
+
$DEBUG = true
|
15
|
+
|
16
|
+
# It's difficult to debug with more than one worker on the go
|
17
|
+
options[:worker_processes] = 1
|
18
|
+
# The default timeout (30s) doesn't leave much time for debugging
|
19
|
+
options[:timeout] = 120
|
20
|
+
end
|
21
|
+
|
22
|
+
daemonize = options.delete(:daemonize)
|
23
|
+
|
24
|
+
# override any settings that you want in your config file
|
25
|
+
options[:config_file] = find_config_file
|
26
|
+
|
27
|
+
# :pid option is stronly discouraged except in unicorn config file
|
28
|
+
uni_options = options.slice(:listeners, :worker_processes, :config_file, :timeout)
|
29
|
+
|
30
|
+
if daemonize
|
31
|
+
::Unicorn::Launcher.daemonize!(uni_options)
|
32
|
+
else
|
33
|
+
::Unicorn.run(app, uni_options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
USER_CONFIG = File.expand_path('~/.hooves')
|
38
|
+
PROJECT_CONFIG = File.expand_path('./.hooves')
|
39
|
+
def find_config_file
|
40
|
+
if user_config?
|
41
|
+
USER_CONFIG
|
42
|
+
elsif project_config?
|
43
|
+
PROJECT_CONFIG
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def user_config?
|
48
|
+
File.exist?(USER_CONFIG)
|
49
|
+
end
|
50
|
+
|
51
|
+
def project_config?
|
52
|
+
File.exist?(PROJECT_CONFIG)
|
21
53
|
end
|
22
54
|
end
|
23
55
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hooves
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jesse Storimer
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-14 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|