Sporny Posted July 23, 2015 Report Share Posted July 23, 2015 I have some Problems with my restarter.pl! When i run it, its running in a loop. Server is online for about 2 minutes, then he restarts again. I've added my restarter.pl ;) #!/usr/bin/perl # # Copyright 2013 by Denis Erygin, # [email protected]<script cf-hash='f9e31' type="text/javascript"> /* */</script> # use warnings; use strict; use constant PORT => 2302; # Change it with epoch.sh use constant PATH => '/home/epoch/epochserver/'; # Set your epoch server dir use constant PIDFILE => PATH.PORT.'.pid'; use constant CACHE_DIR => PATH.'cache/players'; unless (-f PATH.'server') { print STDERR "Can't found server binary!\n"; exit; } set_time (); logrotate (); if (-f PIDFILE) { open (IN, '<'.PIDFILE) or die "Can't open: $!"; my $pid = int(<IN>); close (IN); my $res = `kill -TERM $pid 2>&1`; print STDERR $res,"\n" if $res; unlink (PIDFILE) if (-f PIDFILE); backup_cache(); } print STDERR "Restart Dayz Epoch server...\n"; chdir (PATH); my $cmd = '/usr/bin/screen -h 20000 -fa -d -m -S epoch '.PATH.'epoch.sh'; my $res = `$cmd`; print STDERR $res,"\n" if $res; exit; #----------------------------------------------------------------------------------------------- sub set_time { my ($s, $m, $h, $day, $mon, $y) = localtime(time() - 3*3600); $y += 1900; $mon++; # Uncomment to disabe night #($h, $m) = (17, 0) if ($h > 17 || ($h >= 0 && $h < 4)); my $file = PATH.'cache/set_time.sqf'; open (IN, ">$file") or die "Can't find $file"; # ["PASS", [year, month, day, hour, minute]] print IN '["PASS",[2012,6,6,'.$h.','.$m.']]'; # with full moon close (IN); } sub logrotate { my $log = PATH.'dump.log'; if (-f $log) { my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = stat($log); if ($size && $size >= 100000000) { print STDERR "logrotate $size\n"; my $nlog = $log.'.'.time(); my $res = `cp $log $nlog 2>&1`; print STDERR $res,"\n" if $res; $res = `echo '' > $log 2>&1`; print STDERR $res,"\n" if $res; } } } sub backup_cache { return unless (-d CACHE_DIR); opendir (DIR, CACHE_DIR) or die $!; while (my $file = readdir (DIR)) { next unless ($file =~ m/^\d+$/ && $file ne '1'); my $dir = CACHE_DIR.'/'.$file; my $backup = CACHE_DIR.'/1'; next unless (-d $dir); my $res = `mv -f $dir $backup 2>&1`; print STDERR $res,"\n" if $res; } closedir (DIR); } Link to comment Share on other sites More sharing options...
Swordsworn Posted July 23, 2015 Report Share Posted July 23, 2015 correct me if im totaly wrong here but as far as i remember the linux server wont restart at all if you dont run the restarter.pl manually. keeping that in mind, do you have a crontab or something like that that runs the restarter.pl manually? Could you post your dumb.log? I guess there is a problem that lets your server crash and restarts afterwards. Cheers Swordsworn Link to comment Share on other sites More sharing options...
Sporny Posted July 23, 2015 Author Report Share Posted July 23, 2015 it just restarts in a loop if i run the restarter.pl ;) In a crontab and if i run it manually... the server is runnig without any problems... only the restarter.pl doesnt work Link to comment Share on other sites More sharing options...
Swordsworn Posted July 23, 2015 Report Share Posted July 23, 2015 i just compared your restarter pl with mine the only difference i found is at line 17 yours = unless (-f PATH.'server') { mine = unless (-f PATH.'epoch') { to be honest, I dont really know what exactly it does but as far as i know it handles the start, or better, the processes of the server in general. So thats being said, this could be a solution, but this a totaly blind shot into the blue ;> Link to comment Share on other sites More sharing options...
Sporny Posted July 23, 2015 Author Report Share Posted July 23, 2015 if i change it to 'epoch' it cant find server binaries.... its because i start the server with this line (in epoch.sh): ./server -mod="@dayzoverwatch;@dayz_epoch;@dayz_epoch_server;" -config="cfgdayz/server.cfg" -cfg="cfgdayz/basic.cfg" -port=2302 -beta="expansion/beta;expansion/beta/expansion" -noSound -noPause -world=Chernarus -profiles=cfgdayz -name=cfgdayz -cpucount=2 -exThreads=3 -showscripterrors -pid=2302.pid 2>&1 | ./writer.pl Link to comment Share on other sites More sharing options...
Sporny Posted July 24, 2015 Author Report Share Posted July 24, 2015 Okay.... if i start the restarter.pl manually, it works.... just when the crontab ist active it restarts in a loop.... i will try to find the answer in the other "automatic restart"-thread ;) Link to comment Share on other sites More sharing options...
jahangir13 Posted July 24, 2015 Report Share Posted July 24, 2015 Yes, then yo have set the times wrong in your crontab Please post the line bvut I expect that you've configured it to restart every 2 minute ;)) Link to comment Share on other sites More sharing options...
Swordsworn Posted July 25, 2015 Report Share Posted July 25, 2015 Yes, then yo have set the times wrong in your crontab Please post the line bvut I expect that you've configured it to restart every 2 minute ;)) aaaaye :D i feel like i heard something like that before ;> crontab -e looks like this for me # m h dom mon dow command 0 0,4,8,12,16,20 * * * /home/epoch/serverdownloads/epoch/restarter.pl in your case the very first number should be the interesting thing :) Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now