Lines Matching defs:svc
175 static int service_signal_reset_offline(struct mt_svc *svc);
188 static int mark_service_as_started(struct mt_svc *svc);
224 static int add_svc_conn_spy(struct mt_svc *svc);
232 struct mt_svc *svc;
268 svc = mini->ctx->svc_list;
269 while (svc) {
270 ret = strcasecmp(svc->identity, svc_name);
274 svc = svc->next;
276 if (!svc) {
286 /* Fill in svc structure with connection data */
287 svc->conn = mini->conn;
289 ret = mark_service_as_started(svc);
308 struct mt_svc *svc;
313 struct mt_svc *svc = talloc_get_type(mem, struct mt_svc);
314 if (!svc) {
320 if (svc->mt_ctx) {
321 DLIST_REMOVE(svc->mt_ctx->svc_list, svc);
325 if (svc->pending) {
326 dbus_pending_call_cancel(svc->pending);
329 /* svc is being freed, neutralize the spy */
330 if (svc->conn_spy) {
331 talloc_set_destructor((TALLOC_CTX *)svc->conn_spy, NULL);
332 talloc_zfree(svc->conn_spy);
335 if (svc->type == MT_SVC_SERVICE && svc->svc_started
336 && svc->mt_ctx != NULL && svc->mt_ctx->started_services > 0) {
337 svc->mt_ctx->started_services--;
351 /* svc->conn has been freed, NULL the pointer in svc */
352 spy->svc->conn_spy = NULL;
353 spy->svc->conn = NULL;
357 static int add_svc_conn_spy(struct mt_svc *svc)
361 spy = talloc(svc->conn, struct svc_spy);
364 spy->svc = svc;
366 svc->conn_spy = spy;
372 static void svc_child_info(struct mt_svc *svc, int wait_status)
377 svc->pid, WEXITSTATUS(wait_status));
381 svc->pid, WTERMSIG(wait_status));
384 "Child [%d] did not exit cleanly\n", svc->pid);
386 kill(svc->pid, SIGKILL);
394 static int mark_service_as_started(struct mt_svc *svc)
396 struct mt_ctx *ctx = svc->mt_ctx;
401 DEBUG(SSSDBG_FUNC_DATA, "Marking %s as started.\n", svc->name);
402 svc->svc_started = true;
407 ret = add_svc_conn_spy(svc);
438 if (svc->type == MT_SVC_SERVICE) {
540 static void monitor_restart_service(struct mt_svc *svc);
545 struct mt_svc *svc = talloc_get_type(data, struct mt_svc);
557 sbus_disconnect(svc->conn);
570 static int service_signal_dns_reload(struct mt_svc *svc);
590 static int service_signal(struct mt_svc *svc, const char *svc_signal)
595 if (svc->provider && strcasecmp(svc->provider, "local") == 0) {
600 if (!svc->conn) {
606 "Could not signal service [%s].\n", svc->name);
621 ret = sbus_conn_send(svc->conn, msg,
622 svc->mt_ctx->service_id_timeout,
623 reload_reply, svc, NULL);
629 static int service_signal_dns_reload(struct mt_svc *svc)
631 return service_signal(svc, MON_CLI_IFACE_RESINIT);
633 static int service_signal_offline(struct mt_svc *svc)
635 return service_signal(svc, MON_CLI_IFACE_GOOFFLINE);
637 static int service_signal_reset_offline(struct mt_svc *svc)
639 return service_signal(svc, MON_CLI_IFACE_RESETOFFLINE);
641 static int service_signal_rotate(struct mt_svc *svc)
643 return service_signal(svc, MON_CLI_IFACE_ROTATELOGS);
645 static int service_signal_clear_memcache(struct mt_svc *svc)
647 return service_signal(svc, MON_CLI_IFACE_CLEARMEMCACHE);
649 static int service_signal_clear_enum_cache(struct mt_svc *svc)
651 return service_signal(svc, MON_CLI_IFACE_CLEARENUMCACHE);
653 static int service_signal_sysbus_reconnect(struct mt_svc *svc)
655 return service_signal(svc, MON_CLI_IFACE_SYSBUSRECONNECT);
922 struct mt_svc *svc;
929 svc = talloc_zero(ctx, struct mt_svc);
930 if (!svc) {
933 svc->mt_ctx = ctx;
934 svc->type = MT_SVC_SERVICE;
936 talloc_set_destructor((TALLOC_CTX *)svc, svc_destructor);
938 svc->name = talloc_strdup(svc, name);
939 if (!svc->name) {
940 talloc_free(svc);
944 svc->identity = talloc_strdup(svc, name);
945 if (!svc->identity) {
946 talloc_free(svc);
950 path = talloc_asprintf(svc, CONFDB_SERVICE_PATH_TMPL, svc->name);
952 talloc_free(svc);
956 ret = confdb_get_string(ctx->cdb, svc, path,
958 NULL, &svc->command);
960 DEBUG(SSSDBG_FATAL_FAILURE,"Failed to start service '%s'\n", svc->name);
961 talloc_free(svc);
965 if (svc_supported_as_nonroot(svc->name)) {
970 if (!svc->command) {
971 svc->command = talloc_asprintf(
972 svc, "%s/sssd_%s", SSSD_LIBEXEC_PATH, svc->name
974 if (!svc->command) {
975 talloc_free(svc);
979 svc->command = talloc_asprintf_append(svc->command,
982 if (!svc->command) {
983 talloc_free(svc);
988 svc->command = talloc_asprintf_append(
989 svc->command, " -d %#.4x", cmdline_debug_level
991 if (!svc->command) {
992 talloc_free(svc);
998 svc->command = talloc_asprintf_append(
999 svc->command, " --debug-timestamps=%d", cmdline_debug_timestamps
1001 if (!svc->command) {
1002 talloc_free(svc);
1008 svc->command = talloc_asprintf_append(
1009 svc->command, " --debug-microseconds=%d",
1012 if (!svc->command) {
1013 talloc_free(svc);
1019 svc->command = talloc_strdup_append(
1020 svc->command, " --debug-to-files"
1022 if (!svc->command) {
1023 talloc_free(svc);
1027 svc->command = talloc_strdup_append(
1028 svc->command, " --debug-to-stderr"
1030 if (!svc->command) {
1031 talloc_free(svc);
1037 svc->last_restart = now;
1039 *svc_cfg = svc;
1050 struct mt_svc *svc;
1052 ret = get_service_config(ctx, name, &svc);
1056 svc->restarts = restarts;
1058 ret = start_service(svc);
1060 DEBUG(SSSDBG_FATAL_FAILURE,"Failed to start service '%s'\n", svc->name);
1061 talloc_free(svc);
1072 struct mt_svc *svc;
1077 svc = talloc_zero(ctx, struct mt_svc);
1078 if (!svc) {
1081 svc->mt_ctx = ctx;
1082 svc->type = MT_SVC_PROVIDER;
1084 talloc_set_destructor((TALLOC_CTX *)svc, svc_destructor);
1086 svc->name = talloc_strdup(svc, name);
1087 if (!svc->name) {
1088 talloc_free(svc);
1092 svc->identity = talloc_asprintf(svc, "%%BE_%s", svc->name);
1093 if (!svc->identity) {
1094 talloc_free(svc);
1098 path = talloc_asprintf(svc, CONFDB_DOMAIN_PATH_TMPL, name);
1100 talloc_free(svc);
1104 ret = confdb_get_string(ctx->cdb, svc, path,
1106 NULL, &svc->provider);
1110 talloc_free(svc);
1114 ret = confdb_get_string(ctx->cdb, svc, path,
1116 NULL, &svc->command);
1120 talloc_free(svc);
1127 if (!svc->provider) {
1128 talloc_free(svc);
1133 if (!svc->command) {
1134 svc->command = talloc_asprintf(
1135 svc, "%s/sssd_be --domain %s", SSSD_LIBEXEC_PATH, svc->name
1137 if (!svc->command) {
1138 talloc_free(svc);
1142 svc->command = talloc_asprintf_append(svc->command,
1145 if (!svc->command) {
1146 talloc_free(svc);
1151 svc->command = talloc_asprintf_append(
1152 svc->command, " -d %#.4x", cmdline_debug_level
1154 if (!svc->command) {
1155 talloc_free(svc);
1161 svc->command = talloc_asprintf_append(
1162 svc->command, " --debug-timestamps=%d", cmdline_debug_timestamps
1164 if (!svc->command) {
1165 talloc_free(svc);
1171 svc->command = talloc_asprintf_append(
1172 svc->command, " --debug-microseconds=%d",
1175 if (!svc->command) {
1176 talloc_free(svc);
1182 svc->command = talloc_strdup_append(
1183 svc->command, " --debug-to-files"
1185 if (!svc->command) {
1186 talloc_free(svc);
1190 svc->command = talloc_strdup_append(
1191 svc->command, " --debug-to-stderr"
1193 if (!svc->command) {
1194 talloc_free(svc);
1200 svc->last_restart = now;
1202 *svc_cfg = svc;
1211 struct mt_svc *svc;
1213 ret = get_provider_config(ctx, name, &svc);
1220 svc->restarts = restarts;
1222 if (strcasecmp(svc->provider, "local") == 0) {
1227 svc->svc_started = true;
1228 DLIST_ADD(ctx->svc_list, svc);
1232 ret = start_service(svc);
1234 DEBUG(SSSDBG_FATAL_FAILURE,"Failed to start service '%s'\n", svc->name);
1235 talloc_free(svc);
1288 struct mt_svc *svc;
1298 DLIST_FOR_EACH(svc, mt_ctx->svc_list) {
1299 if (svc->pid == 0) {
1306 "Terminating [%s][%d]\n", svc->name, svc->pid);
1309 kret = kill(svc->pid, SIGTERM);
1313 svc->name, svc->pid, strerror(error));
1319 pid = waitpid(svc->pid, &status, WNOHANG);
1328 error, strerror(error), svc->name);
1330 kill(svc->pid, SIGKILL);
1337 "Child [%s] exited gracefully\n", svc->name);
1340 "Child [%s] terminated with a signal\n", svc->name);
1343 "Child [%s] did not exit cleanly\n", svc->name);
1345 kill(svc->pid, SIGKILL);
1465 struct mt_svc *svc;
1470 for (svc = mon->svc_list; svc; svc = svc->next) {
1471 svc->mt_ctx = NULL;
2294 static int start_service(struct mt_svc *svc)
2299 DEBUG(SSSDBG_CONF_SETTINGS,"Queueing service %s for startup\n", svc->name);
2309 te = tevent_add_timer(svc->mt_ctx->ev, svc, tv,
2310 service_startup_handler, svc);
2313 "Unable to queue service %s for startup\n", svc->name);
2385 struct mt_svc *svc;
2387 svc = talloc_get_type(ptr, struct mt_svc);
2388 if (svc == NULL) {
2393 svc->name, svc->restarts+1);
2395 if (svc->type == MT_SVC_SERVICE) {
2396 add_new_service(svc->mt_ctx, svc->name, svc->restarts + 1);
2397 } else if (svc->type == MT_SVC_PROVIDER) {
2398 add_new_provider(svc->mt_ctx, svc->name, svc->restarts + 1);
2402 "BUG: Invalid child process type [%d]\n", svc->type);
2408 talloc_free(svc);
2413 struct mt_svc *svc = talloc_get_type(pvt, struct mt_svc);
2416 "SIGCHLD handler of service %s called\n", svc->name);
2417 svc_child_info(svc, wait_status);
2420 monitor_restart_service(svc);
2425 static void monitor_restart_service(struct mt_svc *svc)
2427 struct mt_ctx *mt_ctx = svc->mt_ctx;
2436 if ((now - svc->last_restart) > MONITOR_RESTART_CNT_INTERVAL_RESET) {
2437 svc->restarts = 0;
2441 if (svc->restarts > MONITOR_MAX_SVC_RESTARTS) {
2443 "Process [%s], definitely stopped!\n", svc->name);
2447 svc->name);
2449 talloc_free(svc);
2462 restart_delay = svc->restarts << 1;
2468 te = tevent_add_timer(svc->mt_ctx->ev, svc, tv, mt_svc_restart, svc);
2473 talloc_free(svc);