summaryrefslogtreecommitdiff
path: root/luaclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'luaclient.c')
-rw-r--r--luaclient.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/luaclient.c b/luaclient.c
index c721138..75a48e9 100644
--- a/luaclient.c
+++ b/luaclient.c
@@ -231,17 +231,28 @@ int main(int argc, char* argv[])
fclose(pid_file);
}
- // extern global variable defined in l_cmd.c
- cmd_fd = connect_command_socket(opt.command_sock_);
- if(cmd_fd < 0) {
- options_clear(&opt);
- log_close();
- exit(-1);
+ for(;;) {
+ // extern global variable defined in l_cmd.c
+ cmd_fd = connect_command_socket(opt.command_sock_);
+ if(cmd_fd < 0)
+ ret = 2;
+ else {
+ ret = main_loop(cmd_fd, &opt);
+ }
+
+ if(ret == 2) {
+ log_printf(ERROR, "socket error, trying to reconnect in 5 seconds..");
+
+ if(cmd_fd > 0)
+ close(cmd_fd);
+ sleep(5);
+ }
+ else
+ break;
}
- ret = main_loop(cmd_fd, &opt);
-
- close(cmd_fd);
+ if(cmd_fd > 0)
+ close(cmd_fd);
if(!ret)
log_printf(NOTICE, "normal shutdown");