ovn-northd: Ability to detach on Windows.
[cascardo/ovs.git] / ovn / controller-vtep / ovn-controller-vtep.c
index 93a0458..9a3f03b 100644 (file)
@@ -37,6 +37,7 @@
 #include "ovn/lib/ovn-sb-idl.h"
 #include "vtep/vtep-idl.h"
 
+#include "binding.h"
 #include "gateway.h"
 #include "ovn-controller-vtep.h"
 
@@ -57,6 +58,7 @@ main(int argc, char *argv[])
 
     ovs_cmdl_proctitle_init(argc, argv);
     set_program_name(argv[0]);
+    service_start(&argc, &argv);
     parse_options(argc, argv);
     fatal_ignore_sigpipe();
 
@@ -95,6 +97,7 @@ main(int argc, char *argv[])
         };
 
         gateway_run(&ctx);
+        binding_run(&ctx);
         unixctl_server_run(unixctl);
 
         unixctl_server_wait(unixctl);
@@ -104,6 +107,9 @@ main(int argc, char *argv[])
         ovsdb_idl_loop_commit_and_wait(&vtep_idl_loop);
         ovsdb_idl_loop_commit_and_wait(&ovnsb_idl_loop);
         poll_block();
+        if (should_service_stop()) {
+            exiting = true;
+        }
     }
 
     /* It's time to exit.  Clean up the databases. */
@@ -119,6 +125,7 @@ main(int argc, char *argv[])
         /* Run all of the cleanup functions, even if one of them returns false.
          * We're done if all of them return true. */
         done = gateway_cleanup(&ctx);
+        done = binding_cleanup(&ctx) && done;
         if (done) {
             poll_immediate_wake();
         }
@@ -129,11 +136,13 @@ main(int argc, char *argv[])
     }
 
     unixctl_server_destroy(unixctl);
+
     ovsdb_idl_loop_destroy(&vtep_idl_loop);
     ovsdb_idl_loop_destroy(&ovnsb_idl_loop);
 
     free(ovnsb_remote);
     free(vtep_remote);
+    service_stop();
 
     exit(retval);
 }