This repository has been archived by the owner on Feb 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerdns-daemon.rb
53 lines (42 loc) · 1.8 KB
/
dockerdns-daemon.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
49
50
51
52
53
#!/usr/local/rvm/bin/rvm-auto-ruby
require 'optparse'
options = { :action => :run }
daemonize_help = "run daemonized in the background (default: false)"
config_help = "the config file"
pidfile_help = "the pid filename"
logfile_help = "the log filename"
include_help = "an additional $LOAD_PATH (may be used more than once)"
debug_help = "set $DEBUG to true"
warn_help = "enable warnings"
op = OptionParser.new
op.banner = "An example of how to daemonize a long running Ruby process."
op.separator ""
op.separator "Usage: dockerdns-daemon [options]"
op.separator ""
op.separator ""
op.separator "Process options:"
op.on("-d", "--daemonize", daemonize_help) { options[:daemonize] = true }
op.on("-c", "--config CONFIGFILE", config_help) { |value| options[:config] = value }
op.on("-p", "--pid PIDFILE", pidfile_help) { |value| options[:pidfile] = value }
op.on("-l", "--log LOGFILE", logfile_help) { |value| options[:logfile] = value }
op.separator ""
op.separator "Ruby options:"
op.on("-I", "--include PATH", include_help) { |value| $LOAD_PATH.unshift(*value.split(":").map{|v| File.expand_path(v)}) }
op.on( "--debug", debug_help) { $DEBUG = true }
op.on( "--warn", warn_help) { $-w = true }
op.separator ""
op.separator "Common options:"
op.on("-h", "--help") { options[:action] = :help }
op.on("-v", "--version") { options[:action] = :version }
op.separator ""
op.parse!(ARGV)
#==============================================================================
# EXECUTE script
#==============================================================================
require_relative 'lib/server.rb' unless options[:action] == :help
case options[:action]
when :help then puts op.to_s
when :version then puts Server::VERSION
else
Server.run!(options)
end