Fix startup in systemd environments
Signed-off-by: Lon Hohberger <lon@users.sourceforge.net>
This commit is contained in:
parent
9522be50d9
commit
19674ab0bd
@ -7,6 +7,8 @@ Requires=syslog.target network.target
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
Type=forking
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
SysVStartPriority=99
|
SysVStartPriority=99
|
||||||
|
Environment="FENCE_VIRTD_ARGS=-w"
|
||||||
# Autogenerated below here
|
# Autogenerated below here
|
||||||
|
@ -53,7 +53,7 @@ main(int argc, char **argv)
|
|||||||
const backend_plugin_t *p;
|
const backend_plugin_t *p;
|
||||||
listener_context_t listener_ctx = NULL;
|
listener_context_t listener_ctx = NULL;
|
||||||
backend_context_t backend_ctx = NULL;
|
backend_context_t backend_ctx = NULL;
|
||||||
int debug_set = 0, foreground = 0, wait_for_backend = 0;
|
int debug_set = 0, foreground = 0, wait_for_init = 0;
|
||||||
int opt, configure = 0;
|
int opt, configure = 0;
|
||||||
|
|
||||||
config = sc_init();
|
config = sc_init();
|
||||||
@ -81,7 +81,7 @@ main(int argc, char **argv)
|
|||||||
configure = 1;
|
configure = 1;
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
wait_for_backend = 1;
|
wait_for_init = 1;
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
plugin_dump();
|
plugin_dump();
|
||||||
@ -90,7 +90,7 @@ main(int argc, char **argv)
|
|||||||
case '?':
|
case '?':
|
||||||
usage();
|
usage();
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,13 +120,13 @@ main(int argc, char **argv)
|
|||||||
foreground = atoi(val);
|
foreground = atoi(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wait_for_backend) {
|
if (!wait_for_init) {
|
||||||
if (sc_get(config, "fence_virtd/@wait_for_backend",
|
if (sc_get(config, "fence_virtd/@wait_for_init",
|
||||||
val, sizeof(val)) == 0)
|
val, sizeof(val)) == 0)
|
||||||
wait_for_backend = atoi(val);
|
wait_for_init = atoi(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dget() > 3)
|
if (dget() > 3)
|
||||||
sc_dump(config, stdout);
|
sc_dump(config, stdout);
|
||||||
|
|
||||||
if (sc_get(config, "fence_virtd/@backend", backend_name,
|
if (sc_get(config, "fence_virtd/@backend", backend_name,
|
||||||
@ -189,8 +189,10 @@ main(int argc, char **argv)
|
|||||||
signal(SIGTERM, exit_handler);
|
signal(SIGTERM, exit_handler);
|
||||||
signal(SIGQUIT, exit_handler);
|
signal(SIGQUIT, exit_handler);
|
||||||
|
|
||||||
|
syslog(LOG_NOTICE, "fence_virtd starting. Listener: %s Backend: %s", backend_name, listener_name);
|
||||||
|
|
||||||
while (p->init(&backend_ctx, config) < 0) {
|
while (p->init(&backend_ctx, config) < 0) {
|
||||||
if (!wait_for_backend) {
|
if (!wait_for_init) {
|
||||||
if (foreground) {
|
if (foreground) {
|
||||||
printf("Backend plugin %s failed to initialize\n",
|
printf("Backend plugin %s failed to initialize\n",
|
||||||
backend_name);
|
backend_name);
|
||||||
@ -208,20 +210,25 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* only client we have now is mcast (fence_xvm behavior) */
|
/* only client we have now is mcast (fence_xvm behavior) */
|
||||||
if (lp->init(&listener_ctx, p->callbacks, config, map,
|
while (lp->init(&listener_ctx, p->callbacks, config, map,
|
||||||
backend_ctx) < 0) {
|
backend_ctx) != 0) {
|
||||||
if (foreground) {
|
if (!wait_for_init)
|
||||||
printf("Listener plugin %s failed to initialize\n",
|
if (foreground) {
|
||||||
|
printf("Listener plugin %s failed to initialize\n",
|
||||||
|
listener_name);
|
||||||
|
}
|
||||||
|
syslog(LOG_ERR,
|
||||||
|
"Listener plugin %s failed to initialize\n",
|
||||||
listener_name);
|
listener_name);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
syslog(LOG_ERR,
|
sleep(5);
|
||||||
"Listener plugin %s failed to initialize\n",
|
|
||||||
listener_name);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (run && lp->dispatch(listener_ctx, NULL) >= 0);
|
while (run && lp->dispatch(listener_ctx, NULL) >= 0);
|
||||||
|
|
||||||
|
syslog(LOG_NOTICE, "fence_virtd shutting down");
|
||||||
|
|
||||||
map_release(map);
|
map_release(map);
|
||||||
sc_release(config);
|
sc_release(config);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user