about summary refs log tree commit homepage
path: root/bin
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-10-18 10:28:18 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-18 10:28:18 +0000
commitab067831e707b191d6dfdcd01de1f1d85fc90d05 (patch)
treeb02861eb1521fb325ee4e1d91e1a194ca73e7a9e /bin
downloadyahns-ab067831e707b191d6dfdcd01de1f1d85fc90d05.tar.gz
Diffstat (limited to 'bin')
-rwxr-xr-xbin/yahns32
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/yahns b/bin/yahns
new file mode 100755
index 0000000..5c4d34e
--- /dev/null
+++ b/bin/yahns
@@ -0,0 +1,32 @@
+#!/this/will/be/overwritten/or/wrapped/anyways/do/not/worry/ruby
+# -*- encoding: binary -*-
+# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
+# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
+$stdout.sync = $stderr.sync = true
+require 'yahns'
+require 'optparse'
+config_file = daemonize = nil
+OptionParser.new("", 24, "  ") do |opts|
+  cmd = File.basename($0)
+  opts.banner = "Usage: #{cmd} [options]"
+  opts.separator "#{cmd} options:"
+  opts.on("-D", "--daemonize", "run daemonized in the background") do |d|
+    daemonize = !!d
+  end
+  opts.on("-c", "--config-file FILE", "yahns config file") do |f|
+    config_file = f
+  end
+  opts.separator "Common options:"
+  opts.on_tail("-h", "--help", "Show this message") do
+    puts opts.to_s
+    exit
+  end
+  opts.on_tail("-v", "--version", "Show version") do
+    puts "#{cmd} v#{Yahns::VERSION}"
+    exit
+  end
+  opts.parse!(ARGV)
+end
+server = Yahns::Server.new(Yahns::Config.new(config_file))
+Yahns::Daemon.daemon(server) if daemonize
+server.start.join