Jump to content

Automated Messages for restart


Guest JPhix

Recommended Posts

@Devd: how does that work. How can I determine the time in the game. Would be great to know that.

If I restart the server with restarter.pl in between 2 planned restarts the time showing in the debug monitor is obviously wrong.

If the load on the server is heavy and a second is not a second anymore the time is also wrong. Don't want to have the situation where the debug monitor says: restart in 2 minutes and in that moment it already restarts cause the cron job is accurate.

Link to comment
Share on other sites

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

I sometimes have the problem that I have a lot of PHP processes in 'ps aux' because server was not started when cron executed the restart scripts (e.g. if I shutdown the server for changes or something).

 

I check now in my files if the pid is existent under which the server is running (e.g. 2302.pid file in the server dir), if not I exit the scripts.

 

I've added an additional entry in the 'config.php' for the pid file and the code below the variables:

<?php
define("address","localhost");  // server address
define("port","2302");  // server port
define("password","*****");   // battleye password
define("pidfilename","/home/dayzepoch/server1042/2302.pid"); // pid file of server (in server directory. e.g. 2302.pid)

      // check if pid file exists
        $filename = pidfilename;
        $pid = file_get_contents($filename);
        if ( $pid == "" ) $pid = "0";
        $isrunning = false;
        $isrunning = posix_getpgid(intval($pid));
        if ( $isrunning ) {
                echo "Server running. Go on...\n";
        } else {
                echo "Server not started? Exit.\n";
                exit(0);
        }
?>

This prevents executing the say command if server is stopped.

 

EDIT: Hm, I am still getting the Sleeping processes in ps...but however, it was maybe a good idea to stop the execution if the server is not running ;)

Link to comment
Share on other sites

  • 4 weeks later...

You can also use Big Brother Bot for rcon on Linux. It is written in python and it is not a big deal to get it running on linux. There are also a few plugins for use with Arma2 and also a Banlistplugin that can be used ingame. The banlistplugin can be also used for whitelisting (not sure if you have to modify the plugin for that function).

http://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CDAQFjAA&url=http%3A%2F%2Fwww.bigbrotherbot.net%2F&ei=bLZ9U7mAFMOuygOFk4DwAg&usg=AFQjCNGzjw3AkPjCG3D7GVCsooGrSFKjow&bvm=bv.67229260,d.bGQ

Link to comment
Share on other sites

Hi Dew,

 

I've installed B3 and it's running. However I am not quite sure what to use it for ;) I mean, what can it do what I cannot do with the php scripts in this post and cron to restart?

If I want to use it with epoch...I guess it's needed to download and install the Arma2 plugins additionally? Do these plugins support auto-restart and things like that?

Link to comment
Share on other sites

... here are my working crontabs 

#arma server restart
0 */3 * * * /home/dayz/arma2arrowhead/restarter.pl
#restart messages
30 2,5,8,11,14,17,20,23 * * * php -q /home/dayz/restart/30min.php > /dev/null 2>&1
45 2,5,8,11,14,17,20,23 * * * php -q /home/dayz/restart/15min.php > /dev/null 2>&1
50 2,5,8,11,14,17,20,23 * * * php -q /home/dayz/restart/10min.php > /dev/null 2>&1
55 2,5,8,11,14,17,20,23 * * * php -q /home/dayz/restart/5min.php > /dev/null 2>&1
56 2,5,8,11,14,17,20,23 * * * php -q /home/dayz/restart/4min.php > /dev/null 2>&1
57 2,5,8,11,14,17,20,23 * * * php -q /home/dayz/restart/3min.php > /dev/null 2>&1
58 2,5,8,11,14,17,20,23 * * * php -q /home/dayz/restart/2min.php > /dev/null 2>&1
59 2,5,8,11,14,17,20,23 * * * php -q /home/dayz/restart/1min.php > /dev/null 2>&1
regards :-)
Link to comment
Share on other sites

With B3 you can replace BEC. It provides you messages, ingame commands for admins, a user database. There are also arma series plugins

 

There are 3 plugins specifically for arma/battleye servers:

arma2restarts - restarts the server with warnings before doing so and optionally renames all log files.

arma2lobbykick - kicks players who stay in the lobby for too long

arma2admin - can update the battleye script files while the server is running and perform mission restarts, changes etc

They can be found at [email protected]:82ndab-Bravo17/b3-arma2plugins.git

I didn't test them yet, and it is possible that they need a modification for use with Epoch linux. But as soon as i'm done with the whitelist plugin i'm working at, i will check also those plugins

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

Im having abit of problems with my Crontab. These are my settings -
 

*/7 * * * * /apps/dayz/restarter.pl
30 3,7,11,15,19,14 * * * php -q /apps/dayz/Restart/30min.php
45 3,7,11,15,19,14 * * * php -q /apps/dayz/Restart/15min.php
50 3,7,11,15,19,14 * * * php -q /apps/dayz/Restart/10min.php
55 3,7,11,15,19,14 * * * php -q /apps/dayz/Restart/5min.php
56 3,7,11,15,19,14 * * * php -q /apps/dayz/Restart/4min.php
57 3,7,11,15,19,14 * * * php -q /apps/dayz/Restart/3min.php
58 3,7,11,15,19,14 * * * php -q /apps/dayz/Restart/2min.php
59 3,7,11,15,19,14 * * * php -q /apps/dayz/Restart/1min.php

My directories are all correct. I have battleye set to enabled (1) in server.cfg and I have setup my config.php to the following - 

<?php
define("address","54.79.89.46"); // server address
define("port","2302"); // server port
define("password","xxxx"); // battleye password
?>

If it helps I type this "php -q /apps/dayz/Restart/30min.php" (without the quotes) into SSH/Server and I dont receive any messages in game.

Any help would be much appreciated and will definitely consider donating. Thanks

P.S - I have my restart at 7 minutes due to testing.

KaNo5003.
Link to comment
Share on other sites

Hi

If i run the command

php -q /home/dayz/restart/30min.php

 

i get

 

Got Socket!

Attempting Login

 

then nothing, please help me ;-)

 

I've got the same problem, Ive tracked down that the problem isn't logging on, it's this call never returning;

socket_recvfrom($sock, $buf, 64, 0, $ip, $port);

 

DeanReid

could you elaborate about php-cgi, "apt-get install php-cgi" returns no such package

 

OK it's php5-cgi, but how do I add it to the mods list (ubuntu 14.04 server)

Link to comment
Share on other sites

ok heres my Cronjobs 

30 3,7,11,15,19,23 * * * php -q /home/dayz/Restart/30min.php
45 3,7,11,15,19,23 * * * php -q /home/dayz/Restart/15min.php
50 3,7,11,15,19,23 * * * php -q /home/dayz/Restart/10min.php
55 3,7,11,15,19,23 * * * php -q /home/dayz/Restart/5min.php
56 3,7,11,15,19,23 * * * php -q /home/dayz/Restart/4min.php
57 3,7,11,15,19,23 * * * php -q /home/dayz/Restart/3min.php
58 3,7,11,15,19,23 * * * php -q /home/dayz/Restart/2min.php
59 3,7,11,15,19,23 * * * php -q /home/dayz/Restart/1min.php

Download link http://188.165.219.207/Restart.tar.gz

 

simple as edit config.php setup the cronjobs and u have 30 min warnings on restarts

 

 

Anyone have these files anymore?

Link to comment
Share on other sites

I personaly restart my Windows Testserver using callExtension, which calls a shared libary that executes "ExitProcess(0);"
This is a bad behavior of shared libary, but works pretty good with Arma.

The Question is, if the current Linux Version can use callExtension.
If this is not supported, i would recommend an additional command, lets say "876" to the writer.pl that reads the pid file and kills the process.

sub h_killServer {
    my $childPid = shift; // maybe read the pid file at this position
    print "killing $childPid\n";
    if ( ! (waitpid($childPid, WNOHANG)) ) {
        print "killing $childPid...\n";
        kill 9, $childPid;
        die "[$$]: exiting\n";
    }
}

Then you just need to replace

"terminator" callExtension "terminate";

by

diag_log format["CHILD:876"];

My Script:

private ["_warntimes","_warntime","_text"];
_restartEvery = 4; // hours
_warnTimes = [235, 230, 60, 30, 15, 10, 5, 3, 2, 1]; // minutes

if (!isServer) exitWith {};

diag_log(format ["DEBUG RESTART MESSAGE || Inizializing || Servertime: %1 || Missiontime: %2", servertime, time]);
_restartEvery = _restartEvery * 60; // convert to minutes

{ 
	_warntime = (_restartEvery - _x) * 60; // get time without remaining time until restart and convert to seconds
	waituntil {time > _warntime};

	// print warning with remaining _x minutes
	diag_log(format ["DEBUG RESTART MESSAGE || Missiontime: %1 || Restart in %2", time, _x]);
	_text = format ["SERVER RESTART IN %1 MINUTES", _x];
    [nil,nil,rTitleText,_text, "PLAIN",10] call RE;
} forEach _warntimes;

// last warning 30 seconds before restart
waituntil {time > (_restartEvery*60-30)};
diag_log(format ["DEBUG RESTART MESSAGE || Servertime: %1 || Missiontime: %2 || near Restart", servertime, time]);
_text = format ["Logout NOW!", _x];
[nil,nil,rTitleText,_text, "PLAIN",10] call RE;

// exit the ArmA Server when the time has come
waituntil {time > _restartEvery};
"terminator" callExtension "terminate";

// should never reach this point
_text = format ["meh... Restart Failed Oo", _x];
[nil,nil,rTitleText,_text, "PLAIN",10] call RE;

Windows DLL for mingw

#include <windows.h>

#ifdef __cplusplus
extern "C" {
#endif
        __declspec (dllexport) void __stdcall _RVExtension(char *output, int outputSize, const char *function);
#ifdef __cplusplus
}
#endif

void __stdcall _RVExtension(char *output, int outputSize, const char *function) {
        if (strcmp(function, "terminate") == 0) {
                ExitProcess(0);
        } else {
                strncpy(output, function, outputSize);
        }
}
Link to comment
Share on other sites

I've got the same problem, Ive tracked down that the problem isn't logging on, it's this call never returning;

socket_recvfrom($sock, $buf, 64, 0, $ip, $port);

 

DeanReid

could you elaborate about php-cgi, "apt-get install php-cgi" returns no such package

 

OK it's php5-cgi, but how do I add it to the mods list (ubuntu 14.04 server)

 

Just casting my programmers eyes over the code again....

 

where is $buf declared?  the socket_recvfrom() call is the first instance of $buf in every one of the files. Just curious as $sock, $ip and $port are declared earlier in the code and for me at least this is the call that never returns.

Link to comment
Share on other sites

Try using the files on my github, they are a copy from my server I have a feeling something broke somewhere, if mine dont work then its probably php, make a info.php in your web dir and then copy this in

<?php phpinfo(); ?>
 
It should look like this 

phpinfo.png

 

or this..

 

ac60970160c7768caa754345640b92a8.png

 

and this. 

 

a23eaf3acc2ee2359a3176a36d1d2bf0.png

 

Just search CGI and it should find it, if not then its not installed/mounted correctly, make sure you restart apache, forgot to mention this

Link to comment
Share on other sites

  • 2 weeks later...

Scripts executed from cron live in a very different environment than the ones you run in a shell. In particular, the value of $PATH and the default directory may be different from what you think. It is usually a good idea to specify full paths to binaries in cron, e.g. "/usr/bin/php5" instead of just "php"

 

Also, the RCON implementation here is probably broken. I will get around to write a better one some day soon.

 

Just casting my programmers eyes over the code again....

 

where is $buf declared?  the socket_recvfrom() call is the first instance of $buf in every one of the files. Just curious as $sock, $ip and $port are declared earlier in the code and for me at least this is the call that never returns.

 

The call never returns because it blocks - it waits for input from the server. The connection code is broken and doesn't detect an error (and because this is UDP, the error might not be even detectable). Double check that the values in config.php - and especially the port - are correct. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

  • Discord

×
×
  • Create New...