rack-handler-apache 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +37 -7
- data/lib/rack/handler/apache.rb +18 -6
- metadata +2 -2
data/README.md
CHANGED
@@ -18,7 +18,7 @@ or
|
|
18
18
|
|
19
19
|
rackup -s apache config.ru
|
20
20
|
|
21
|
-
This will run a minimally
|
21
|
+
This will run a minimally configured Apache instance as the current user. When you control-c your app,
|
22
22
|
the server will shutdown too.
|
23
23
|
|
24
24
|
Yes, this is not the right way to run your production rails apps!
|
@@ -28,12 +28,42 @@ Yes, this is running as you, so there are the usual security issues!
|
|
28
28
|
But it might be handy!!
|
29
29
|
|
30
30
|
|
31
|
-
|
31
|
+
Configuration Options
|
32
|
+
---------------------
|
32
33
|
|
33
|
-
*
|
34
|
-
* Default configurations
|
35
|
-
* How SSL support works
|
34
|
+
* Port
|
36
35
|
|
37
|
-
|
36
|
+
Port defaults to 8080
|
38
37
|
|
39
|
-
*
|
38
|
+
* Host
|
39
|
+
|
40
|
+
Interface to listen on. Default is 127.0.0.1.
|
41
|
+
|
42
|
+
* SSLEnable
|
43
|
+
|
44
|
+
Boolean to enable use of SSL. Deafult is false.
|
45
|
+
If SSL is enables, then SSLCertificateFile and SSLPrivateKeyFile
|
46
|
+
must be set.
|
47
|
+
|
48
|
+
* SSLCertificateFile
|
49
|
+
|
50
|
+
The SSL Certificate file name. (Note this is the file name, not a
|
51
|
+
certificate object, like in Webricks SSLCertificate)
|
52
|
+
|
53
|
+
* SSLPrivateKeyFile
|
54
|
+
|
55
|
+
The SSL Private Key file name. (Again this is not the key object)
|
56
|
+
|
57
|
+
* ServerConfig
|
58
|
+
|
59
|
+
Additional httpd.conf lines for server.
|
60
|
+
|
61
|
+
* HostConfig
|
62
|
+
|
63
|
+
Additional httpd.conf lines for <VirtualHost> section.
|
64
|
+
|
65
|
+
|
66
|
+
Things todo
|
67
|
+
-----------
|
68
|
+
|
69
|
+
* Better config customisation - if anyone needs it
|
data/lib/rack/handler/apache.rb
CHANGED
@@ -10,23 +10,32 @@ module Rack
|
|
10
10
|
|
11
11
|
def self.valid_options
|
12
12
|
{
|
13
|
-
"Port=PORT"
|
14
|
-
|
13
|
+
"Port=PORT" => "Port to listen on (default: 8080)",
|
14
|
+
"Host=HOST" => "Hostname to listen on (default: 127.0.0.1)",
|
15
|
+
"SSLEnable=BOOL" => "Enable https",
|
16
|
+
"SSLCertificateFile=FILENAME" => "SSL Certificate file name",
|
17
|
+
"SSLPrivateKeyFile=FILENAME" => "SSL Private Key file name",
|
18
|
+
"ServerConfig=TEXT" => "Additional httpd.conf lines for server",
|
19
|
+
"HostConfig=TEXT" => "Additional httpd.conf lines for virtual host"
|
15
20
|
}
|
16
21
|
end
|
17
22
|
|
18
23
|
def self.run(app, options={})
|
19
24
|
|
20
25
|
unless ::File.exists? ::PhusionPassenger::APACHE2_MODULE
|
21
|
-
puts "Passenger apache module missing, did you run passenger-install-apache2-module?"
|
26
|
+
puts "Fatal: Passenger apache module missing, did you run passenger-install-apache2-module?"
|
22
27
|
exit
|
23
28
|
end
|
24
29
|
|
25
30
|
@root = ::Dir.pwd
|
26
31
|
@port = options[:Port] || 8080
|
32
|
+
@host = options[:Host] || '127.0.0.1'
|
27
33
|
@pid_file = "#{@root}/tmp/rack-helper-apache.pid"
|
28
34
|
@conf_file = "#{@root}/tmp/httpd.conf"
|
29
|
-
|
35
|
+
|
36
|
+
# Find the right passenger-install-apache2-module to get the config snipper
|
37
|
+
piam = ::File.expand_path("../../bin/passenger-install-apache2-module", $".find {|f|f=~/phusion_passenger.rb$/})
|
38
|
+
@passenger = `#{piam} --snippet`
|
30
39
|
|
31
40
|
puts "Warning: Please use SSLCertificateFile, not SSLCertificate" if
|
32
41
|
options[:SSLCertificate] && !options[:SSLCertificateFile]
|
@@ -37,7 +46,7 @@ module Rack
|
|
37
46
|
config = <<-EOD.gsub(/^ {10}/, '')
|
38
47
|
#{@passenger}
|
39
48
|
User #{Etc.getlogin}
|
40
|
-
Listen #{@port}
|
49
|
+
Listen #{@host}:#{@port}
|
41
50
|
PidFile #{@pid_file}
|
42
51
|
ErrorLog #{$stdout.ttyname}
|
43
52
|
LockFile #{@root}/tmp/rack-helper-apache.lock
|
@@ -50,7 +59,9 @@ module Rack
|
|
50
59
|
AllowOverride all
|
51
60
|
Options -MultiViews
|
52
61
|
</Directory>
|
62
|
+
#{options[:HostConfig]}
|
53
63
|
</VirtualHost>
|
64
|
+
#{options[:ServerConfig]}
|
54
65
|
EOD
|
55
66
|
|
56
67
|
if options[:SSLEnable]
|
@@ -73,6 +84,7 @@ module Rack
|
|
73
84
|
|
74
85
|
if is_running?
|
75
86
|
puts "...started [pid:#{get_pid}]"
|
87
|
+
puts "Available at #{options[:SSLEnable]?'https':'http'}://#{@host}:#{@port}"
|
76
88
|
sleep 0.5 while is_running?
|
77
89
|
puts "Apache terminated."
|
78
90
|
else
|
@@ -117,7 +129,7 @@ module Rack
|
|
117
129
|
def self.is_running?
|
118
130
|
if pid=get_pid
|
119
131
|
begin
|
120
|
-
::Process.kill 0, pid
|
132
|
+
::Process.kill 0, pid # 0 => check if process exists
|
121
133
|
return true
|
122
134
|
rescue Errno::ESRCH => e
|
123
135
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-handler-apache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|