From ab067831e707b191d6dfdcd01de1f1d85fc90d05 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Oct 2013 10:28:18 +0000 Subject: initial commit --- bin/yahns | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 bin/yahns (limited to 'bin') 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 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 -- cgit v1.2.3-24-ge0c7