## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+TOP_DIR = File.expand_path(File.dirname(__FILE__))
$:.unshift File.dirname(__FILE__)
require 'shogi_server'
def main
- setup_watchdog_for_giant_lock
-
$options = parse_command_line
if (ARGV.length != 2)
usage
usage
exit 3
end
+ if $options["pid-file"]
+ $options["pid-file"] = File.expand_path($options["pid-file"])
+ end
LEAGUE.event = ARGV.shift
port = ARGV.shift
log_file = dir ? File.join(dir, "shogi-server.log") : STDOUT
$logger = setup_logger(log_file)
- LEAGUE.dir = dir || File.dirname(__FILE__)
- LEAGUE.setup_players_database
+ LEAGUE.dir = dir || TOP_DIR
config = {}
config[:Port] = port
config[:Logger] = $logger
fg_thread = nil
+
config[:StartCallback] = Proc.new do
if $options["pid-file"]
write_pid_file($options["pid-file"])
end
+ setup_watchdog_for_giant_lock
+ LEAGUE.setup_players_database
fg_thread = setup_floodgate
end
config[:StopCallback] = Proc.new do
if $options["pid-file"]
- FileUtils.rm(pid_file, :force => true)
+ FileUtils.rm($options["pid-file"], :force => true)
end
end
Thread.abort_on_exception = $DEBUG ? true : false
begin
- LEAGUE = ShogiServer::League::new
+ LEAGUE = ShogiServer::League.new(TOP_DIR)
main
rescue Exception => ex
log_error("main: #{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}")