Commits

Daniel Poelzleithner committed 1b9a40a

add start delay option to static backend
first fixes to work with git elliptics
add server exit lua function

  • Participants
  • Parent commits 6e9a8b8

Comments (0)

Files changed (6)

 
 config 'backend' 'static'
     option 'enabled' 'on'
+    option 'delay' '10'
     option 'sleep' '0'
     list 'ipv4' '127.0.0.1:2344'
     list 'ipv4' 'somehost:2344'

File src/backends/libdssd.lua

+-- dssd bindings lua written extensions
+
+
 function dssd.parse_ip(str)
     local host, port = string.match(str, "([^: ]+):(%d+)")
     if host then

File src/backends/static.lua

 print(uci.get(dssd_server.uci_context, 'dssd.static.sleep'))
 
 while true do
+    local delay = tonumber(uci.get(dssd_server.uci_context, 'dssd.static.delay'))
+    if delay and delay > 0 then
+        dssd.sleep(delay)
+    end
     connect_statics()
     local sleep = tonumber(uci.get(dssd_server.uci_context, 'dssd.static.sleep'))
     if (not sleep or sleep == 0) then
 	char *historyf = NULL, *root = NULL, *removef = NULL, *config_path = NULL;
     char *config_name = NULL;
 	unsigned char trans_id[DNET_ID_SIZE], *id = NULL;
+
+    dssd_do_exit = 0;
 	FILE *log = NULL;
     pthread_t lua_thread;
 
 
     start_lua_threads();
 
-    //dnet_give_up_control(node);
+    //dnet_give_up_control(dssd_server_node);
+    while (!dssd_do_exit)
+		sleep(1);
     //sleep(1);
-    wait_for_threads();
+    //wait_for_threads();
 
     dssd_log(DNET_LOG_INFO, "exit dssd daemon normally\n");
 
 
 struct dnet_config *dssd_server_config;
 struct dnet_node *dssd_server_node;
+int dssd_do_exit;
+
 
 struct uci_basic_config {
     struct ucimap_section_data map;
     return 0;
 }
 
+static int dssdL_exit(lua_State *L) {
+    dssd_do_exit = 1;
+    return 0;
+}
+
 
 
 #if DEBUG
   {"id_cmp",        dnetL_id_cmp},
   {"log",           dssdL_log},
   {"sleep",         dssdL_sleep},
+  {"exit_server",   dssdL_exit},
   {0, 0}
 };