Skip to content

Commit

Permalink
Merge pull request #19 from rafalmiel/systemd-cp-15132
Browse files Browse the repository at this point in the history
CP-15132: Systemd conversion
  • Loading branch information
robhoes authored Aug 25, 2016
2 parents 6545681 + 5bc9428 commit 6b02ca1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Executable forkexecd
MainIs: fe_main.ml
Custom: true
Install: false
BuildDepends: stdext, forkexec, uuidm
BuildDepends: stdext, forkexec, uuidm, systemd

Executable fe_test
CompiledObject: best
Expand Down
1 change: 1 addition & 0 deletions opam
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ remove: [make "uninstall" "BINDIR=%{bin}%" "SBINDIR=%{bin}%" "ETCDIR=%{prefix}%/
depends: [
"ocamlfind" {build}
"oasis" {build}
"systemd" {build}
"syslog"
"rpc"
"fd-send-recv"
Expand Down
18 changes: 1 addition & 17 deletions src/fe_main.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

(** 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 syslog_stdout redirect_stderr_to_stdout env =
Expand Down Expand Up @@ -45,23 +41,11 @@ let setup sock cmdargs id_to_fd_map syslog_stdout redirect_stderr_to_stdout env
end

let _ =
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 Stdext.Unixext.daemonize ();

Sys.set_signal Sys.sigpipe (Sys.Signal_ignore);

let main_sock = Fecomms.open_unix_domain_sock_server "/var/xapi/forker/main" in

Stdext.Unixext.pidfile_write !pidfile;
Daemon.notify Daemon.State.Ready;

(* At this point the init.d script should return and we are listening on our socket. *)

Expand Down

0 comments on commit 6b02ca1

Please sign in to comment.