camper_van 0.0.9 → 0.0.10
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/bin/camper_van +13 -2
- data/lib/camper_van/channel.rb +2 -2
- data/lib/camper_van/server.rb +29 -0
- data/lib/camper_van/version.rb +1 -1
- data/spec/camper_van/channel_spec.rb +12 -0
- metadata +3 -4
- data/Gemfile.lock +0 -48
data/bin/camper_van
CHANGED
@@ -36,11 +36,16 @@ Options:
|
|
36
36
|
stop_on "proxy"
|
37
37
|
|
38
38
|
opt :log_level, "Log level", :default => "info"
|
39
|
-
opt :log_file, "Log file", :short => "f", :type => :string
|
39
|
+
opt :log_file, "Log file (required when running as a daemon)", :short => "f", :type => :string
|
40
40
|
opt :ssl, "Enable SSL for IRC client connections"
|
41
41
|
opt :ssl_private_key, "Path to SSL private key file for IRC client connections, defaults to self-signed", :type => :string
|
42
42
|
opt :ssl_cert, "Path to SSL cert file for IRC client connections, defaults to self-signed", :type => :string
|
43
43
|
opt :ssl_verify_peer, "Verify peers for IRC client connections"
|
44
|
+
|
45
|
+
opt :daemon, 'Daemonizes the process'
|
46
|
+
|
47
|
+
opt :pid, 'Path of the PID file', :type => :string,
|
48
|
+
:default => '/var/run/camper_van.pid'
|
44
49
|
end
|
45
50
|
|
46
51
|
opts = Trollop.with_standard_exception_handling parser do
|
@@ -50,6 +55,10 @@ opts = Trollop.with_standard_exception_handling parser do
|
|
50
55
|
raise Trollop::HelpNeeded
|
51
56
|
end
|
52
57
|
|
58
|
+
if o[:daemon] and !o[:log_file]
|
59
|
+
raise Trollop::HelpNeeded
|
60
|
+
end
|
61
|
+
|
53
62
|
o
|
54
63
|
end
|
55
64
|
|
@@ -69,7 +78,9 @@ else
|
|
69
78
|
:ssl => opts[:ssl],
|
70
79
|
:ssl_private_key => opts[:ssl_private_key],
|
71
80
|
:ssl_cert => opts[:ssl_cert],
|
72
|
-
:ssl_verify_peer => opts[:ssl_verify_peer]
|
81
|
+
:ssl_verify_peer => opts[:ssl_verify_peer],
|
82
|
+
:daemon => opts[:daemon],
|
83
|
+
:pid => opts[:pid]
|
73
84
|
)
|
74
85
|
|
75
86
|
end
|
data/lib/camper_van/channel.rb
CHANGED
@@ -43,11 +43,11 @@ module CamperVan
|
|
43
43
|
# false if the room was full or locked.
|
44
44
|
def join
|
45
45
|
if room.locked?
|
46
|
-
numeric_reply :err_inviteonlychan, "Cannot join #{channel} (locked)"
|
46
|
+
client.numeric_reply :err_inviteonlychan, "Cannot join #{channel} (locked)"
|
47
47
|
return false
|
48
48
|
|
49
49
|
elsif room.full?
|
50
|
-
numeric_reply :err_channelisfull, "Cannot join #{channel} (full)"
|
50
|
+
client.numeric_reply :err_channelisfull, "Cannot join #{channel} (full)"
|
51
51
|
return false
|
52
52
|
|
53
53
|
else
|
data/lib/camper_van/server.rb
CHANGED
@@ -14,6 +14,8 @@ module CamperVan
|
|
14
14
|
# :ssl_private_key - if using ssl, private key file to use, defaults to self-signed
|
15
15
|
# :ssl_cert - if using ssl, cert file to use, defaults to self-signed
|
16
16
|
# :ssl_verify_peer - if using ssl, verify client certificates, defaults to false
|
17
|
+
# :daemon - if camper_van should daemonize itself
|
18
|
+
# :pid - the path of the PID file to use.
|
17
19
|
def self.run(bind_address="localhost", port=6667, options={})
|
18
20
|
|
19
21
|
initialize_logging options
|
@@ -22,6 +24,11 @@ module CamperVan
|
|
22
24
|
logger = Logging.logger[self.name]
|
23
25
|
logger.info "starting server on #{bind_address}:#{port}"
|
24
26
|
EM.start_server bind_address, port, self, options
|
27
|
+
|
28
|
+
if options[:daemon]
|
29
|
+
daemonize(logger, options[:pid])
|
30
|
+
end
|
31
|
+
|
25
32
|
trap("INT") do
|
26
33
|
logger.info "SIGINT, shutting down"
|
27
34
|
EM.stop
|
@@ -29,6 +36,28 @@ module CamperVan
|
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
39
|
+
# Turns the current process into a daemon.
|
40
|
+
#
|
41
|
+
# logger - The logger to use
|
42
|
+
# pid - The path to the PID file
|
43
|
+
#
|
44
|
+
def self.daemonize(logger, pid)
|
45
|
+
if !File.writable?(pid)
|
46
|
+
logger.error "The PID file #{pid} is not writable"
|
47
|
+
abort
|
48
|
+
end
|
49
|
+
|
50
|
+
logger.info "Daemonizing camper_van using PID #{pid}"
|
51
|
+
|
52
|
+
Process.daemon
|
53
|
+
|
54
|
+
File.open(pid, 'w') do |handle|
|
55
|
+
handle.write(Process.pid.to_s)
|
56
|
+
end
|
57
|
+
|
58
|
+
Logging.reopen
|
59
|
+
end
|
60
|
+
|
32
61
|
# Initialize the logging system
|
33
62
|
#
|
34
63
|
# opts - Hash of logging options
|
data/lib/camper_van/version.rb
CHANGED
@@ -123,6 +123,18 @@ describe CamperVan::Channel do
|
|
123
123
|
@channel.join
|
124
124
|
@room.stream_count.must_equal 1
|
125
125
|
end
|
126
|
+
|
127
|
+
it "returns an error if the room is locked" do
|
128
|
+
@room.locked = true
|
129
|
+
@channel.join
|
130
|
+
@client.sent.last.must_match /Cannot join #test.*locked/
|
131
|
+
end
|
132
|
+
|
133
|
+
it "returns an error if the room is full" do
|
134
|
+
@room.full = true
|
135
|
+
@channel.join
|
136
|
+
@client.sent.last.must_match /Cannot join #test.*full/
|
137
|
+
end
|
126
138
|
end
|
127
139
|
|
128
140
|
describe "#part" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camper_van
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
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: 2013-05-
|
12
|
+
date: 2013-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
@@ -102,7 +102,6 @@ files:
|
|
102
102
|
- .gitignore
|
103
103
|
- .rvmrc
|
104
104
|
- Gemfile
|
105
|
-
- Gemfile.lock
|
106
105
|
- Guardfile
|
107
106
|
- LICENSE
|
108
107
|
- Procfile
|
@@ -150,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
149
|
version: '0'
|
151
150
|
segments:
|
152
151
|
- 0
|
153
|
-
hash:
|
152
|
+
hash: -1732883802111020027
|
154
153
|
requirements: []
|
155
154
|
rubyforge_project: camper_van
|
156
155
|
rubygems_version: 1.8.23
|
data/Gemfile.lock
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
camper_van (0.0.9)
|
5
|
-
eventmachine (~> 0.12.10)
|
6
|
-
firering (~> 1.2.0)
|
7
|
-
logging (~> 1.5.1)
|
8
|
-
trollop (~> 1.16.2)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: http://rubygems.org/
|
12
|
-
specs:
|
13
|
-
addressable (2.2.7)
|
14
|
-
em-http-request (0.3.0)
|
15
|
-
addressable (>= 2.0.0)
|
16
|
-
escape_utils
|
17
|
-
eventmachine (>= 0.12.9)
|
18
|
-
escape_utils (0.2.4)
|
19
|
-
eventmachine (0.12.10)
|
20
|
-
ffi (1.0.11)
|
21
|
-
firering (1.2.2)
|
22
|
-
em-http-request (~> 0.3.0)
|
23
|
-
eventmachine (~> 0.12.10)
|
24
|
-
yajl-ruby (~> 0.7.6)
|
25
|
-
growl (1.0.3)
|
26
|
-
guard (1.0.1)
|
27
|
-
ffi (>= 0.5.0)
|
28
|
-
thor (~> 0.14.6)
|
29
|
-
guard-minitest (0.5.0)
|
30
|
-
guard (>= 0.4)
|
31
|
-
little-plugger (1.1.3)
|
32
|
-
logging (1.5.2)
|
33
|
-
little-plugger (>= 1.1.2)
|
34
|
-
rake (0.9.2.2)
|
35
|
-
rb-fsevent (0.9.0)
|
36
|
-
thor (0.14.6)
|
37
|
-
trollop (1.16.2)
|
38
|
-
yajl-ruby (0.7.9)
|
39
|
-
|
40
|
-
PLATFORMS
|
41
|
-
ruby
|
42
|
-
|
43
|
-
DEPENDENCIES
|
44
|
-
camper_van!
|
45
|
-
growl
|
46
|
-
guard-minitest
|
47
|
-
rake
|
48
|
-
rb-fsevent
|