With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
Pre SG 1.0 archive

Stand-alone dedicated server suggestions

Postby hika » Fri Aug 11, 2006 12:02 am

I think this topic could be the place for any WQ3 server admins ;)

I have a suggestion / wish about how can a wq3ded behave about system's signals :
Is it possible to handle the signal 1 (e.g SIGHUP) in order to reload the config files and parse the pk3 files in search paths, one more time ?
That way, we can avoid any server restarts when it comes to a config file change or some new pk3 files adds.
So, in case, WQ3 servers are always full (which I hope in the futur ;)), we can avoid kicking all players when the server admin just wants to change something.

If needed, this is a part where I could help.
I can start from the original Q3 source files.
If patchs will be available, then I think it is more appropriate to incorporate these in the standalone version, first.
Then, why not for the other quake3 forks : icculus, FreeBSD's quake3 and cleanq3 ... etc

Oh ... and I forget about Windows ... I don't think it will know anything about signals :lol:
So, if anyone have some other alternatives, just let us know ;)
Last edited by hika on Fri Aug 11, 2006 10:55 am, edited 1 time in total.
SG name: Manchot
SG fansite: http://western.bsdmon.com
Image
userbar originally created by Caffeine
User avatar
hika
SG Team
 
Posts: 703
Joined: Thu May 25, 2006 2:32 pm
Location: Trévoux, France



Postby ReD NeCKersoN » Fri Aug 11, 2006 12:13 am

Both of our coders are on vacation so it'll be a week or two before they can discuss these things with you. :wink:
User avatar
ReD NeCKersoN
SG Team
 
Posts: 3245
Joined: Wed Mar 27, 2002 6:22 am
Location: VA, USA



Postby hika » Fri Aug 11, 2006 12:30 am

ReD NeCKersoN wrote:Both of our coders are on vacation so it'll be a week or two before they can discuss these things with you. :wink:

Yeah, I know that torhu and sig11 are having fun with holidays ;).
They will see that topic when the time comes.
BTW, I will be off too, for a few days. I'm actually on vacation (for only 2 weeks)
SG name: Manchot
SG fansite: http://western.bsdmon.com
Image
userbar originally created by Caffeine
User avatar
hika
SG Team
 
Posts: 703
Joined: Thu May 25, 2006 2:32 pm
Location: Trévoux, France



Postby ReD NeCKersoN » Fri Aug 11, 2006 2:20 am

When do you leave? Dammit, no more updated test servers for awhile I guess. :? And we had something very special in store for the testers this Saturday. 8O Trust me, it's a BIG surprise.
User avatar
ReD NeCKersoN
SG Team
 
Posts: 3245
Joined: Wed Mar 27, 2002 6:22 am
Location: VA, USA



Postby hika » Fri Aug 11, 2006 10:53 am

ReD NeCKersoN wrote:When do you leave?

I will be gone, next week (my last week), probably Wednesday.
So, we can expect BIG surprise, this week end :D
SG name: Manchot
SG fansite: http://western.bsdmon.com
Image
userbar originally created by Caffeine
User avatar
hika
SG Team
 
Posts: 703
Joined: Thu May 25, 2006 2:32 pm
Location: Trévoux, France



Postby Caffeine » Sat Aug 12, 2006 2:52 am

Works for me. :)
Caffeine
Pistolero
 
Posts: 44
Joined: Mon Mar 13, 2006 9:33 am
Location: Michigan



Postby hika » Sun Aug 13, 2006 6:11 pm

When analysing a bit the Quake 3 source files, I have found a way to handle the system's signal.
I have also found how we can reload the config file given by the following command line (In this case, it is server.cfg)
Code: Select all
q3ded +set fs_game westernq3 +set dedicated 1 +exec server.cfg


However, I have lost my time :(, since the server admin can easily do the same by executing the following command in the console
Code: Select all
\rcon exec server.cfg

By doing this, the server just reinterpret the config file, and btw, reload the cvars and start the default map (that trigger a map change).
I noticed that a map change trigger another pk3 parse in the search paths (see console log on each map change).
That way, newly put pk3 files will be loaded.

Anyway, I can provide a small patch to handle the SIGHUP signal and do the same as this \rcon exec <myconfig.cfg>, if anyone (playing with Linux or *BSD) are interested ...
SG name: Manchot
SG fansite: http://western.bsdmon.com
Image
userbar originally created by Caffeine
User avatar
hika
SG Team
 
Posts: 703
Joined: Thu May 25, 2006 2:32 pm
Location: Trévoux, France



Postby sig11 » Tue Aug 15, 2006 8:31 pm

I think this is generally a good idea.

And in the end, you may not even have wasted your time ;-) ... the server configuration file can be called anything, not just server.cfg (In fact, mine are called differently for the different servers). If it is possible to remember the exec command and re-execute it after receiving a SIGHUP, this could be very useful.

And yes, a map_restart or a map change does at least a partial reset of the search path etc.

But either way, I'm interested in your patch ! Maybe we can do something with it.
In-game name: =SG= Django (yes, it's cliché :-) )
User avatar
sig11
SG Team
 
Posts: 616
Joined: Sun Mar 30, 2003 1:00 pm
Location: Germany



Postby hika » Tue Aug 15, 2006 9:58 pm

sig11 wrote:If it is possible to remember the exec command and re-execute it after receiving a SIGHUP, this could be very useful.

sig11 wrote:But either way, I'm interested in your patch ! Maybe we can do something with it.


Here is the following patch, made from the original quake3-1.32b-source.zip source file, to handle the SIGHUP signal :

Code: Select all
--- ./code/unix/linux_signals.c.orig    Tue Aug 16 01:10:07 2005
+++ ./code/unix/linux_signals.c Tue Aug 15 21:38:23 2006
@@ -40,6 +40,28 @
   }
 
   signalcaught = qtrue;

+#ifdef DEDICATED
+  // Only for dedicated server
+  switch(sig)
+  {
+    case SIGHUP:
+      printf("Received signal %d, reloading...\n", sig);
+     
+      // Add possible startup commands, given on command line,
+      // in the command text buffer
+      if ( Com_AddStartupCommands() )
+      {
+        // Then, execute them
+        Cbuf_Execute();
+      }
+      // Signal has been caught
+      signalcaught = qfalse;
+      return;
+      break;
+  }
+#endif

   printf("Received signal %d, exiting...\n", sig);
 #ifndef DEDICATED
   GLimp_Shutdown(); // bk010104 - shouldn't this be CL_Shutdown

(The endlines are in \r\n style ! Not \n UNIX style !)

To comment the code, I know that Com_AddStartupCommands() gets the Q3 commands given from command line ("+exec server.cfg" for example), and add them to some text buffer.
Then Cbuf_Execute() execute all commands stored in the text buffer, and remove them from the buffer.
That way, following the example, the "exec server.cfg" will be re-executed, and, of course, a map change will be done by launching the default map.
SG name: Manchot
SG fansite: http://western.bsdmon.com
Image
userbar originally created by Caffeine
User avatar
hika
SG Team
 
Posts: 703
Joined: Thu May 25, 2006 2:32 pm
Location: Trévoux, France



Postby sig11 » Thu Aug 17, 2006 6:29 pm

I've applied the patch against my development version and tested it a bit. Looks very good !
And simply re-executing the command line seems to be indeed the best and simplest way ! Thanks, hika ! It will most likely make it into the next SA version.

Maybe I'll add anothe signal handler (for e.g. USR1/USR2) to restart the current map and to change to the next map - or maybe not ;-) ... or maybe I'll give the game a possibility to store its PID to a file (just like any decent UNIX server ...).
In-game name: =SG= Django (yes, it's cliché :-) )
User avatar
sig11
SG Team
 
Posts: 616
Joined: Sun Mar 30, 2003 1:00 pm
Location: Germany



Postby hika » Sat Aug 19, 2006 7:39 pm

Glad that I could help 8)
I hope this feature will be very helpful !

sig11 wrote:Maybe I'll add anothe signal handler (for e.g. USR1/USR2) to restart the current map and to change to the next map - or maybe not ;-) ... or maybe I'll give the game a possibility to store its PID to a file (just like any decent UNIX server ...).

About the PID file, if implementation is planned, what about a cvar to store its path ?
And then, something like
Code: Select all
kill -1 `cat /path/to/pidfile`
will be certainly more interesting than a
Code: Select all
pkill -1 wqded
or
Code: Select all
killall -1 wqded
especially if there are multiple wqded instance.

If needed, I could help about these tiny things, as I guess there are not very important for the stand alone project (and wq3 players) ;)
Just some comfort for server admins.
SG name: Manchot
SG fansite: http://western.bsdmon.com
Image
userbar originally created by Caffeine
User avatar
hika
SG Team
 
Posts: 703
Joined: Thu May 25, 2006 2:32 pm
Location: Trévoux, France



Postby sig11 » Tue Aug 22, 2006 2:36 pm

hika wrote:About the PID file, if implementation is planned, what about a cvar to store its path ?

Yes.
And then, something like
Code: Select all
kill -1 `cat /path/to/pidfile`
will be certainly more interesting than a
Code: Select all
pkill -1 wqded
or
Code: Select all
killall -1 wqded
especially if there are multiple wqded instance.

Exactly. 8)
If needed, I could help about these tiny things, as I guess there are not very important for the stand alone project (and wq3 players) ;)
Just some comfort for server admins.

Actually, lately the code changes to the SA are all of that sort of nature ;-) ... all the important stuff is there like smooth integration of engine and game and some important fixes like the ATI skybox fix.
My current list is more or less:
- see if ioq3 or similar projects found any serious bugs
- Fix a demo file-name case mismatch between load and save (only affecting Unix)
- Allow for UID change and chrooting the server (half way there 8) ... and I porbably will have to make it w/o cvars :? )
- The PID/signal handling stuff
(Note: the bug you found about the dynamite throwing close to the wall: I don't know yet, if it's the engine or the game - maybe somebody else knows already)

But if you want to do something there, go ahead ! In unix/unix_main.c in main(), the cvars are parsed when doing Com_Init(cmdline). So, sometime after that, possibly in the #ifdef section a few lines further down might be a good place to dispatch to save the PID.
In-game name: =SG= Django (yes, it's cliché :-) )
User avatar
sig11
SG Team
 
Posts: 616
Joined: Sun Mar 30, 2003 1:00 pm
Location: Germany



Postby hika » Fri Aug 25, 2006 12:39 am

I have made some patches to handle the PID save in a file.
A cvar named sv_pidfile can be set to change the file path.
When stopping the dedicated server, PID file unlink is also handled.
I have add a signal handler for SIGINT, typically when we kill the dedicated server by CTRL+C

Anyway, here are the file patches made from quake3-1.32b-source.zip
http://wq3.bsdmon.com/stuff/patch-code-unix-linux_signals.c
http://wq3.bsdmon.com/stuff/patch-code-unix-unix_main.c

However, I guess some fixes like handling permission and PID file path are needed if chroot and setuid are planned.
Either way, just take what you need, as I don't think code will be let as is ;)
SG name: Manchot
SG fansite: http://western.bsdmon.com
Image
userbar originally created by Caffeine
User avatar
hika
SG Team
 
Posts: 703
Joined: Thu May 25, 2006 2:32 pm
Location: Trévoux, France



Postby sig11 » Wed Aug 30, 2006 9:04 pm

Cool !

Too bad, I was rather busy the last few days :( ... and now the URL does not really answer ... I somehow remember you talking about your setup but I forgot ;-) ... If you want to, you can just mail me, to either s1g11@westernquake3.net (that's three 1's in s1g11) or sig11@bootblock.de
in the meantime, I will keep trying to download.
In-game name: =SG= Django (yes, it's cliché :-) )
User avatar
sig11
SG Team
 
Posts: 616
Joined: Sun Mar 30, 2003 1:00 pm
Location: Germany



Postby hika » Wed Aug 30, 2006 9:50 pm

sig11 wrote:... and now the URL does not really answer ...

Yeah, too bad, 'cause my home server has just crashed the past few days.
Now, you should normally reach the URLs.
SG name: Manchot
SG fansite: http://western.bsdmon.com
Image
userbar originally created by Caffeine
User avatar
hika
SG Team
 
Posts: 703
Joined: Thu May 25, 2006 2:32 pm
Location: Trévoux, France



Next

Return to Stand-alone Testing

Show Sidebar
Show Sidebar

User Control Panel

cron