File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
class App
2
2
def call ( env )
3
3
if env [ 'PATH_INFO' ] == '/'
4
- [ 200 , { 'Content-Type' => 'text/html' } , [ ' Hello from the rack application inside config.ru.' ] ]
4
+ [ 200 , { 'Content-Type' => 'text/html' } , [ " Hello from the rack application inside config.ru with PID: #{ Process . pid } \n " ] ]
5
5
else
6
6
[ 404 , { 'Content-Type' => 'text/html' } , [ 'Boo.' ] ]
7
7
end
Original file line number Diff line number Diff line change @@ -8,11 +8,30 @@ def initialize port
8
8
@server = TCPServer . new port
9
9
end
10
10
11
+ def prefork
12
+ 3 . times do
13
+ fork do
14
+ start
15
+ end
16
+ end
17
+
18
+ waitall
19
+ end
20
+
21
+ def waitall
22
+ Process . waitall
23
+
24
+ rescue Interrupt
25
+ puts "\n Killed all. No zombies."
26
+ end
27
+
11
28
def start
12
29
loop do
13
30
socket = @server . accept
14
31
Thread . new { SocketHandler . new ( socket ) . process }
15
32
end
33
+
34
+ rescue Interrupt
16
35
end
17
36
end
18
37
@@ -95,4 +114,4 @@ def close_socket
95
114
96
115
server = Hyperloop . new 3000
97
116
puts "Starting Hyperloop server on port 3000"
98
- server . start
117
+ server . prefork
You can’t perform that action at this time.
0 commit comments