launch 1.0 → 2.0.0
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/CHANGELOG.md +12 -0
- data/LICENSE +19 -0
- data/README.md +65 -0
- data/ext/extconf.rb +17 -0
- data/ext/launch.c +272 -0
- data/lib/launch.bundle +0 -0
- data/lib/launch.rb +7 -80
- data/lib/launch/errors.rb +22 -0
- data/lib/launch/job.rb +170 -0
- data/lib/launch/test_helper.rb +11 -0
- data/lib/launch/version.rb +3 -0
- data/lib/launch/webrick.rb +21 -27
- data/test/launch/job_test.rb +9 -0
- data/test/launch/service_test.rb +23 -0
- data/test/launch_test.rb +11 -0
- metadata +55 -135
- data.tar.gz.sig +0 -1
- data/.autotest +0 -8
- data/.gemtest +0 -0
- data/History.txt +0 -5
- data/Manifest.txt +0 -11
- data/README.txt +0 -72
- data/Rakefile +0 -37
- data/ext/launch/extconf.rb +0 -6
- data/ext/launch/launch.c +0 -355
- data/sample/echo.rb +0 -107
- data/test/test_launch.rb +0 -55
- metadata.gz.sig +0 -2
data/sample/echo.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'launch'
|
3
|
-
|
4
|
-
##
|
5
|
-
# This is an echo server that runs using launchd on port 12345.
|
6
|
-
#
|
7
|
-
# To start, run:
|
8
|
-
#
|
9
|
-
# ruby echo.rb net.segment7.launch.echo.plist
|
10
|
-
# launchctl load net.segment7.launch.echo.plist
|
11
|
-
#
|
12
|
-
# To use the echo server run:
|
13
|
-
#
|
14
|
-
# telnet localhost 12345
|
15
|
-
#
|
16
|
-
# To quit the echo server type ^] followed by ^D
|
17
|
-
#
|
18
|
-
# To stop run:
|
19
|
-
#
|
20
|
-
# launchctl unload net.segment7.launch.echo.plist
|
21
|
-
|
22
|
-
class Echo
|
23
|
-
|
24
|
-
include Launch
|
25
|
-
|
26
|
-
def self.plist name
|
27
|
-
file = File.expand_path __FILE__
|
28
|
-
root = File.expand_path '../..', __FILE__
|
29
|
-
|
30
|
-
plist = <<-PLIST
|
31
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
32
|
-
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
33
|
-
<plist version="1.0">
|
34
|
-
<dict>
|
35
|
-
<key>Label</key>
|
36
|
-
<string>#{name}</string>
|
37
|
-
<key>ProgramArguments</key>
|
38
|
-
<array>
|
39
|
-
<string>#{Gem.ruby}</string>
|
40
|
-
<string>-I#{root}/lib</string>
|
41
|
-
<string>-I#{root}/ext</string>
|
42
|
-
<string>#{file}</string>
|
43
|
-
</array>
|
44
|
-
<key>ServiceIPC</key>
|
45
|
-
<true/>
|
46
|
-
<key>Sockets</key>
|
47
|
-
<dict>
|
48
|
-
<key>EchoSocket</key>
|
49
|
-
<dict>
|
50
|
-
<key>SockServiceName</key>
|
51
|
-
<string>12345</string>
|
52
|
-
</dict>
|
53
|
-
</dict>
|
54
|
-
</dict>
|
55
|
-
</plist>
|
56
|
-
PLIST
|
57
|
-
|
58
|
-
open name, 'w' do |io|
|
59
|
-
io.write plist
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def initialize
|
64
|
-
launch_checkin
|
65
|
-
end
|
66
|
-
|
67
|
-
##
|
68
|
-
# echo lines sent from +socket+
|
69
|
-
|
70
|
-
def echo socket
|
71
|
-
Thread.start do
|
72
|
-
loop do
|
73
|
-
socket.puts socket.gets
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
##
|
79
|
-
# Listens on +server+ for connections to echo on.
|
80
|
-
|
81
|
-
def listen server
|
82
|
-
Thread.start do
|
83
|
-
loop do
|
84
|
-
echo server.accept
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
##
|
90
|
-
# Starts listening on the sockets given by launchd and waits forever
|
91
|
-
|
92
|
-
def run
|
93
|
-
launch_sockets('EchoSocket', TCPServer).each do |server|
|
94
|
-
listen server
|
95
|
-
end
|
96
|
-
|
97
|
-
sleep
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
if ARGV.empty? then
|
103
|
-
Echo.new.run
|
104
|
-
else
|
105
|
-
Echo.plist ARGV.first
|
106
|
-
end
|
107
|
-
|
data/test/test_launch.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'launch'
|
3
|
-
|
4
|
-
class TestLaunch < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
include Launch
|
7
|
-
|
8
|
-
def launch_message message
|
9
|
-
@message = message
|
10
|
-
|
11
|
-
return { 'response' => 'hash' }
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_launch_checkin
|
15
|
-
response = launch_checkin
|
16
|
-
|
17
|
-
assert_equal Launch::Key::CHECKIN, @message
|
18
|
-
|
19
|
-
expected = { 'response' => 'hash' }
|
20
|
-
|
21
|
-
assert_equal expected, response
|
22
|
-
assert_equal expected, @launch_checkin
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_launch_sockets
|
26
|
-
@launch_checkin = {
|
27
|
-
Launch::JobKey::SOCKETS => {
|
28
|
-
'MySockets' => [STDIN.to_i, STDOUT.to_i]
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
sockets = launch_sockets 'MySockets', IO
|
33
|
-
|
34
|
-
assert_equal 2, sockets.length
|
35
|
-
|
36
|
-
assert_instance_of IO, sockets.first
|
37
|
-
assert_instance_of IO, sockets.last
|
38
|
-
|
39
|
-
assert_equal [0, 1], sockets.map { |io| io.to_i }
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_launch_sockets_none
|
43
|
-
@launch_checkin = {
|
44
|
-
Launch::JobKey::SOCKETS => {
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
e = assert_raises Launch::Error do
|
49
|
-
launch_sockets 'NoSockets', IO
|
50
|
-
end
|
51
|
-
|
52
|
-
assert_equal 'no sockets found for "NoSockets"', e.message
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
metadata.gz.sig
DELETED