CVSROOT: ciabot.pl Test forking + xmlrpc.
arekm
arekm at pld-linux.org
Thu Nov 22 19:47:24 CET 2007
Author: arekm Date: Thu Nov 22 18:47:24 2007 GMT
Module: CVSROOT Tag: HEAD
---- Log message:
Test forking + xmlrpc.
---- Files affected:
CVSROOT:
ciabot.pl (1.15 -> 1.16)
---- Diffs:
================================================================
Index: CVSROOT/ciabot.pl
diff -u CVSROOT/ciabot.pl:1.15 CVSROOT/ciabot.pl:1.16
--- CVSROOT/ciabot.pl:1.15 Wed Nov 21 21:56:58 2007
+++ CVSROOT/ciabot.pl Thu Nov 22 19:47:19 2007
@@ -36,6 +36,7 @@
#
use strict;
+use POSIX 'setsid';
use vars qw ($project $from_email $dest_email $rpc_uri $sendmail $sync_delay
$xml_rpc $ignore_regexp $alt_local_message_target);
@@ -82,7 +83,7 @@
# while they allow outgoing mail. Also, this script will hang and eventually
# not deliver the event at all if CIA server happens to be down, which is
# unfortunately not an uncommon condition.
-$xml_rpc = 0;
+$xml_rpc = 1;
# You can make this bot to totally ignore events concerning the objects
# specified below. Each object is composed of <module>/<path>/<filename>,
@@ -126,6 +127,17 @@
#
$" = "\7";
+sub daemonize {
+ chdir '/' or die "Can't chdir to /: $!";
+ open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
+ open STDOUT, '>/dev/null'
+ or die "Can't write to /dev/null: $!";
+ defined(my $pid = fork) or die "Can't fork: $!";
+ exit if $pid;
+ setsid or die "Can't start a new session: $!";
+ open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
+}
+
### Input data loading
@@ -308,6 +320,8 @@
if ($xml_rpc) {
+ daemonize();
+
# We gotta be careful from now on. We silence all the warnings because
# RPC::XML code is crappy and works with undefs etc.
$^W = 0;
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/CVSROOT/ciabot.pl?r1=1.15&r2=1.16&f=u
More information about the pld-cvs-commit
mailing list