r5704 - in packages/trunk/pokerth/debian: . patches
Evgeni Golov
sargentd-guest at alioth.debian.org
Sun Feb 10 20:10:59 UTC 2008
Author: sargentd-guest
Date: 2008-02-10 20:10:59 +0000 (Sun, 10 Feb 2008)
New Revision: 5704
Added:
packages/trunk/pokerth/debian/patches/05_server_options_svn-r1393.dpatch
Modified:
packages/trunk/pokerth/debian/patches/00list
packages/trunk/pokerth/debian/pokerth-server.init
Log:
add a patch from upstream svn, pokerth-server is now able to write pidfiles \o/
Modified: packages/trunk/pokerth/debian/patches/00list
===================================================================
--- packages/trunk/pokerth/debian/patches/00list 2008-02-09 02:30:53 UTC (rev 5703)
+++ packages/trunk/pokerth/debian/patches/00list 2008-02-10 20:10:59 UTC (rev 5704)
@@ -2,3 +2,4 @@
02_use_dejavu_fonts
03_fix_gcc43_ftbfs
04_sane_server_defaults
+05_server_options_svn-r1393
Added: packages/trunk/pokerth/debian/patches/05_server_options_svn-r1393.dpatch
===================================================================
--- packages/trunk/pokerth/debian/patches/05_server_options_svn-r1393.dpatch (rev 0)
+++ packages/trunk/pokerth/debian/patches/05_server_options_svn-r1393.dpatch 2008-02-10 20:10:59 UTC (rev 5704)
@@ -0,0 +1,106 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 05_server_options_svn-r1393.dpatch by Evgeni Golov <sargentd at die-welt.net>
+##
+## DP: Add some commandline options and pid-file handling to the server
+## DP: imported from the upstream svn at r1393
+
+ at DPATCH@
+
+Index: pokerth/src/pokerth_server.cpp
+===================================================================
+--- pokerth.orig/src/pokerth_server.cpp (revision 1392)
++++ pokerth/src/pokerth_server.cpp (working copy)
+@@ -24,8 +24,11 @@
+ #include <qttoolsinterface.h>
+ #include <gui/generic/serverguiwrapper.h>
+ #include <net/socket_startup.h>
++#include <net/netpacket.h>
+ #include <core/loghelper.h>
+ #include <core/thread.h>
++#include <boost/program_options.hpp>
++#include <boost/filesystem.hpp>
+
+ #include <memory>
+ #include <csignal>
+@@ -49,6 +52,8 @@
+ #endif
+
+ using namespace std;
++namespace po = boost::program_options;
++using namespace boost::filesystem;
+
+ volatile int g_pokerthTerminate = 0;
+
+@@ -59,7 +64,9 @@
+ }
+
+ // TODO: Hack
+-#ifndef _WIN32
++#ifdef _WIN32
++ #include <process.h>
++#else
+ #include <unistd.h>
+ #ifndef daemon
+ int daemon(int, int);
+@@ -73,6 +80,39 @@
+
+ // _CrtSetBreakAlloc(4772);
+
++ bool readonlyConfig = false;
++ string pidFile;
++ {
++ // Check command line options.
++ po::options_description desc("Allowed options");
++ desc.add_options()
++ ("help,h", "produce help message")
++ ("version,v", "print version string")
++ ("pid-file,p", po::value<string>(), "create pid-file in different location")
++ ("readonly-config", "treat config file as read-only")
++ ;
++
++ po::variables_map vm;
++ po::store(po::parse_command_line(argc, argv, desc), vm);
++ po::notify(vm);
++
++ if (vm.count("help"))
++ {
++ cout << desc << endl;
++ return 1;
++ }
++ if (vm.count("version"))
++ {
++ cout << "PokerTH server version " << POKERTH_BETA_RELEASE_STRING << endl
++ << "Network protocol version " << NET_VERSION_MAJOR << "." << NET_VERSION_MINOR << endl;
++ return 1;
++ }
++ if (vm.count("pid-file"))
++ pidFile = vm["pid-file"].as<string>();
++ if (vm.count("readonly-config"))
++ readonlyConfig = true;
++ }
++
+ auto_ptr<QtToolsInterface> myQtToolsInterface(CreateQtToolsWrapper());
+ //create defaultconfig
+ ConfigFile *myConfig = new ConfigFile(argc, argv);
+@@ -91,6 +131,21 @@
+ LOG_MSG("Starting PokerTH dedicated server. Availability: IPv6 "
+ << socket_has_ipv6() << ", SCTP " << socket_has_sctp() << ", Dual Stack " << socket_has_dual_stack() << ".");
+
++ // Store pid in file.
++ if (pidFile.empty())
++ {
++ path tmpPidPath(myConfig->readConfigString("LogDir"));
++ tmpPidPath /= "pokerth.pid";
++ pidFile = tmpPidPath.directory_string();
++ }
++ {
++ ofstream pidStream(pidFile.c_str(), ios_base::out | ios_base::trunc);
++ if (!pidStream.fail())
++ pidStream << getpid();
++ else
++ LOG_ERROR("Could not create process id file \"" << pidFile << "\"!");
++ }
++
+ // Create pseudo Gui Wrapper for the server.
+ boost::shared_ptr<GuiInterface> myServerGuiInterface(new ServerGuiWrapper(myConfig, NULL, NULL, NULL));
+ boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig));
Modified: packages/trunk/pokerth/debian/pokerth-server.init
===================================================================
--- packages/trunk/pokerth/debian/pokerth-server.init 2008-02-09 02:30:53 UTC (rev 5703)
+++ packages/trunk/pokerth/debian/pokerth-server.init 2008-02-10 20:10:59 UTC (rev 5704)
@@ -17,9 +17,9 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/games
DESC="PokerTH server"
NAME=pokerth-server
+PIDFILE=/var/run/$NAME.pid
DAEMON=/usr/games/pokerth_server
-DAEMON_ARGS=""
-PIDFILE=/var/run/$NAME.pid
+DAEMON_ARGS="-p $PIDFILE"
SCRIPTNAME=/etc/init.d/$NAME
STARTAS_USER=pokerth
STARTAS_GRP=pokerth
More information about the Pkg-games-commits
mailing list