forked from mortenbpost/eservices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapper.pl
42 lines (33 loc) · 759 Bytes
/
wrapper.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Exiled.Net IRC Services.
# $Id: wrapper.pl,v 1.1.1.1 2002/08/20 15:20:02 mr Exp $
#
# Simple wrapper script to automatically restart
# services after a crash, and copy the executable
# and the core-file to a seperate subdirectory
# so it can be debugged later.
#!/usr/bin/perl
use File::Copy;
use strict;
my $execfile = "./services";
my $corefile = "./services.core";
my $err = -1;
my $lastexit = 0;
while ($err)
{
$err = system($execfile);
printf("Returned> $err\n");
if ($err)
{
my $ctime = time();
printf("$ctime\n");
copy($execfile, "cores/$ctime");
copy($corefile, "cores/$ctime.core");
system("rm -f $corefile");
}
if ((time() - $lastexit) < (60*5))
{
$err = 0;
}
$lastexit = time();
sleep 60;
}