OSDN Git Service

[shogi-server] Create a directory for a PID file. (Closes #38546)
authorDaigo Moriwaki <daigo@debian.org>
Sun, 26 Aug 2018 00:14:48 +0000 (09:14 +0900)
committerDaigo Moriwaki <daigo@debian.org>
Sun, 26 Aug 2018 00:14:48 +0000 (09:14 +0900)
To put a PID file such as /var/run/shogi-server/shogi-server.pid, if
directories do not exist, they will be created recursively.

changelog
shogi-server

index b3df157..600d5a4 100644 (file)
--- a/changelog
+++ b/changelog
@@ -4,6 +4,10 @@
          A file named "STOP" in the base directory prevents the server from
          starting new games including Floodgate matches.
          (Closes #38544)
+       * [shogi-server] Create a directory for a PID file.
+         To put a PID file such as /var/run/shogi-server/shogi-server.pid, if
+         directories do not exist, they will be created recursively.
+         (Closes #38546)
 
 2018-04-07  Daigo Moriwaki <daigo at debian dot org>
 
index 21bc9d1..f1cfbb3 100755 (executable)
@@ -34,6 +34,7 @@ require 'shogi_server'
 require 'shogi_server/config'
 require 'shogi_server/util'
 require 'shogi_server/league/floodgate_thread.rb'
+require 'pathname'
 require 'tempfile'
 
 #################################################
@@ -271,6 +272,8 @@ def check_command_line
 
   if $options["pid-file"] 
     $options["pid-file"] = File.expand_path($options["pid-file"], $topdir)
+    path = Pathname.new($options["pid-file"])
+    path.dirname().mkpath()
     unless ShogiServer::is_writable_file? $options["pid-file"]
       usage
       $stderr.puts "Can not create the pid file: %s" % [$options["pid-file"]]