-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhotspotd.rb
executable file
·48 lines (39 loc) · 950 Bytes
/
hotspotd.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/ruby
require 'drb'
require 'hotlib'
require 'hotserver'
#load 'hotspotd.conf'
class HotSpotD
def initialize()
@log = HotLogger.instance.log
if ARGV.length > 0 and ARGV[0] == '-f'
fork_launch()
else
launch()
end
end
def launch()
server = HotServer.new
DRb.start_service(HotConfig::URI, server)
@log.info("lithium hotspot daemon started...")
DRb.thread.join
end
def fork_launch()
pid = fork
if pid == nil
Process.setsid
exit if fork #zap session leader
#free file descriptors
STDIN.reopen "/dev/null"
STDOUT.reopen "/dev/null", "a"
STDERR.reopen "/dev/null"
HotLogger.instance.set_to_file(HotConfig::LOGFILE)
@log = HotLogger.instance.log
launch()
else
#@log.info("forked, pid=#{pid}")
exit
end
end
end
HotSpotD.new