mirror of
https://github.com/troglobit/finit.git
synced 2026-12-04 21:58:19 +00:00
Add support for service restart counter.
This commit adds a statistics counter to the finit svc_t process struct which is incremented every time a process is restarted by the service monitor. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
f277166354
commit
89675403d8
2 files changed
+6
-1
No files matched your search
@@ -262,8 +262,10 @@ void svc_monitor(void)
|
|||||||
procname_kill(name, SIGTERM);
|
procname_kill(name, SIGTERM);
|
||||||
|
|
||||||
/* Restarting lost service. */
|
/* Restarting lost service. */
|
||||||
if (svc_enabled(svc, 0, NULL))
|
if (svc_enabled(svc, 0, NULL)) {
|
||||||
|
svc->stat_restart_counter++;
|
||||||
svc_start(svc);
|
svc_start(svc);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -383,6 +385,7 @@ int svc_stop(svc_t *svc)
|
|||||||
if (svc->pid <= 1) {
|
if (svc->pid <= 1) {
|
||||||
_d("Bad PID %d for %s, SIGTERM", svc->pid, svc->desc);
|
_d("Bad PID %d for %s, SIGTERM", svc->pid, svc->desc);
|
||||||
svc->pid = 0;
|
svc->pid = 0;
|
||||||
|
svc->stat_restart_counter = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,6 +394,7 @@ int svc_stop(svc_t *svc)
|
|||||||
res = kill(svc->pid, SIGTERM);
|
res = kill(svc->pid, SIGTERM);
|
||||||
print_result(res);
|
print_result(res);
|
||||||
svc->pid = 0;
|
svc->pid = 0;
|
||||||
|
svc->stat_restart_counter = 0;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ typedef enum {
|
|||||||
typedef struct svc {
|
typedef struct svc {
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int reload;
|
int reload;
|
||||||
|
unsigned int stat_restart_counter; /* Incremented for each restart by service monitor. */
|
||||||
char cmd[MAX_ARG_LEN];
|
char cmd[MAX_ARG_LEN];
|
||||||
char args[MAX_NUM_SVC_ARGS][MAX_ARG_LEN];
|
char args[MAX_NUM_SVC_ARGS][MAX_ARG_LEN];
|
||||||
char desc[MAX_STR_LEN];
|
char desc[MAX_STR_LEN];
|
||||||
|
|||||||
Reference in new issue
Block a user