Hello,

As on many systems init scripts and the handling of services is based on pid 
files I extended the mtt-relay script as follows:

If run with the --daemon option
* Create file /var/run/mtt-relay.pid  if it does not exist and write the pid of 
the background process into it.
* exit with return value 1 if /var/run/mtt-relay.pid file exists.

Patch is attached.

Best regards
Christoph Niethammer

--

Christoph Niethammer
High Performance Computing Center Stuttgart (HLRS)
Nobelstrasse 19
70569 Stuttgart

Tel: ++49(0)711-685-87203
email: nietham...@hlrs.de
http://www.hlrs.de/people/niethammer
--- /home/hpcmtt/mtt-trunk/client/mtt-relay.orig        2013-09-30 11:35:59.637400212 +0200
+++ /home/hpcmtt/mtt-trunk/client/mtt-relay     2013-09-30 11:45:19.496180413 +0200
@@ -93,6 +93,10 @@
     #     exit;
     # }
 
+    my $pidfilename = "/var/run/mtt-relay.pid";
+    if (-e $pidfilename) {
+        exit 1;
+    }
     my $master = new HTTP::Daemon
             LocalAddr => $HOST, LocalPort => $PORT or 
             die "Problem creating an HTTP::Daemon: $!";
@@ -103,6 +107,9 @@
         my $pid = fork();
         if($pid) {
             print "# Daemon Parent exiting\n";
+            open PIDFILE, ">$pidfilename";
+            print PIDFILE $pid;
+            close PIDFILE;
             exit 0;
         } else {
             print "# Daemon Child process continuing\n";

Reply via email to