WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH 2 of 6] CA-33440: Add [-daemon] and [-pidfile] argument

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 2 of 6] CA-33440: Add [-daemon] and [-pidfile] arguments to the fork/exec daemon
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Fri, 18 Dec 2009 20:51:14 +0000
Delivery-date: Fri, 18 Dec 2009 12:50:29 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1261169472@xxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1261169314 0
# Node ID befce8a7c74ac27572baac4ffddc0dc5c721f080
# Parent  5861a396a46c196844dd7d4cb7d35df0e62a6a0c
CA-33440: Add [-daemon] and [-pidfile] arguments to the fork/exec daemon.

This will make it easier to write an init.d script.

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r 5861a396a46c -r befce8a7c74a forking_executioner/fe_main.ml
--- a/forking_executioner/fe_main.ml    Fri Dec 18 20:48:33 2009 +0000
+++ b/forking_executioner/fe_main.ml    Fri Dec 18 20:48:34 2009 +0000
@@ -1,3 +1,7 @@
+
+(** We write our PID here when we're ready to receive connections. *)
+let default_pidfile = "/var/run/fe.pid"
+
 open Fe_debug
 
 let setup sock cmdargs id_to_fd_map env =
@@ -39,10 +43,25 @@
   end
 
 let _ =
-  (* Unixext.daemonize ();*)
+  let pidfile = ref default_pidfile in
+  let daemonize = ref false in
+ 
+  Arg.parse (Arg.align [
+              "-daemon", Arg.Set daemonize, "Create a daemon";
+              "-pidfile", Arg.Set_string pidfile, Printf.sprintf "Set the pid 
file (default \"%s\")" !pidfile;
+            ])
+    (fun _ -> failwith "Invalid argument")
+    "Usage: fe [-daemon] [-pidfile filename]";
+
+  if !daemonize then Unixext.daemonize ();
+
   Sys.set_signal Sys.sigpipe (Sys.Signal_ignore);
 
   let main_sock = Fecomms.open_unix_domain_sock_server "/var/xapi/forker/main" 
in
+
+  Unixext.pidfile_write !pidfile;
+
+  (* At this point the init.d script should return and we are listening on our 
socket. *)
 
   while true do
     try
1 file changed, 20 insertions(+), 1 deletion(-)
forking_executioner/fe_main.ml |   21 ++++++++++++++++++++-


Attachment: xen-api-libs.hg-6.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api