[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 2 of 6] CA-33440: Add [-daemon] and [-pidfile] arguments to the fork/exec daemon



# 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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.