]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - .inspircd.inc
Added more fault tolerance to server links
[user/henk/code/inspircd.git] / .inspircd.inc
index a3032f6764b075b5f88253dd39e4d690c4517ab1..5900ce9c6f77b50e9c7c265718941cf3d79cdecb 100644 (file)
 #               I HATE PERL.. kthxbye
 # ---------------------------------------------------
 
+$ENV{"LD_LIBRARY_PATH"} = $ENV{"LD_LIBRARY_PATH"} . ":/usr/local/lib/mysql:/usr/lib/mysql";
+
 my $conffile = "@CONFIG_DIR@/inspircd.conf";
-my $binpath = "@BINARY_DIR@/inspircd";
+my $binpath = "@BINARY_DIR@";
 
 # Lets see what they want to do.. Set the variable (Cause i'm a lazy coder)
 my $arg = $ARGV[0];
 getpidfile();
 
 if ($arg eq "start") { start(); exit(); }
+if ($arg eq "debug") { debug(); exit(); }
 if ($arg eq "stop") { stop(); exit(); }
 if ($arg eq "status") {
        if (getstatus() == 1) { 
@@ -47,7 +50,8 @@ if ($arg eq "rehash") {
 }
 
 if ($arg eq "cron") {
-       if (getstatus() == 0) { start(); exit(); }
+       if (getstatus() == 0) { start(); }
+       exit();
 }
 
 if ($arg eq "restart") {
@@ -78,28 +82,43 @@ sub start {
         # Check to see its not 'running' already.
         if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
         # If we are still alive here.. Try starting the IRCd..
-        system($binpath);
+        system("$binpath/inspircd");
         sleep 1;
         if (getstatus() == 0) {
                 print "InspIRCd Seemingly not started, Log follows:\n";
-                system("tail ircd.log");
+                system("tail $binpath/ircd.log");
         } else {
                 # We're good!
                 return 1;
         }
 }
 
+sub debug {
+        # Check to see its not 'running' already.
+        if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; }
+        # If we are still alive here.. Try starting the IRCd..
+        system("gdb --args $binpath/inspircd -nofork -debug");
+}
+
+
 sub stop {
-        if (getstatus() == 0) { print "InspIRCd is not running. (Or PID File not found)"; return 0; }
+        if (getstatus() == 0) { print "InspIRCd is not running. (Or PID File not found)\n"; return 0; }
         # Get to here, we have something to kill.
         my $pid = getprocessid();
+       print "Stopping InspIRCd...\n";
         system("kill -TERM $pid >/dev/null 2>&1");
+       sleep 2;
+       if (getstatus() == 1)
+       {
+               print "InspIRCd not dying Quietly -- Forcing Kill\n";
+               system("kill -9 $pid >/dev/null 2>&1");
+       }
         print "InspIRCd Stopped.\n";
 }
 
 
 sub getpidfile {
-       open INFILE, "<  $conffile" or die "Couldn't open $conffile";
+       open INFILE, "<  $conffile" or die "Couldn't open $conffile\n";
        my(@lines) = <INFILE>;
        close INFILE;
        chomp(@lines);
@@ -125,7 +144,7 @@ sub getstatus {
 
 sub getprocessid {
        my $pid;
-       open PIDFILE, "< $pidfile" or die "Cannot open PID";
+       open PIDFILE, "< $pidfile" or return 0;
        while($i = <PIDFILE>)
        {
                $pid = $i;