mirror of
https://github.com/troglobit/finit.git
synced 2026-11-08 16:11:10 +00:00
Set a default description for all services
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
fcfbd57ca8
commit
a7e52914d2
2 files changed
+16
-4
No files matched your search
@@ -475,8 +475,10 @@ int service_register(int type, char *line, time_t mtime, char *username)
|
|||||||
}
|
}
|
||||||
|
|
||||||
desc = strstr(line, "-- ");
|
desc = strstr(line, "-- ");
|
||||||
if (desc)
|
if (desc) {
|
||||||
*desc = 0;
|
*desc = 0;
|
||||||
|
desc += 3;
|
||||||
|
}
|
||||||
|
|
||||||
cmd = strtok(line, " ");
|
cmd = strtok(line, " ");
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
@@ -574,7 +576,7 @@ recreate:
|
|||||||
|
|
||||||
svc->log = log;
|
svc->log = log;
|
||||||
if (desc)
|
if (desc)
|
||||||
strlcpy(svc->desc, desc + 3, sizeof(svc->desc));
|
strlcpy(svc->desc, desc, sizeof(svc->desc));
|
||||||
|
|
||||||
if (username) {
|
if (username) {
|
||||||
char *ptr = strchr(username, ':');
|
char *ptr = strchr(username, ':');
|
||||||
@@ -759,8 +761,7 @@ restart:
|
|||||||
svc_set_state(svc, SVC_HALTED_STATE);
|
svc_set_state(svc, SVC_HALTED_STATE);
|
||||||
} else if (cond_get_agg(svc->cond) == COND_ON) {
|
} else if (cond_get_agg(svc->cond) == COND_ON) {
|
||||||
if (*restart_counter >= RESPAWN_MAX) {
|
if (*restart_counter >= RESPAWN_MAX) {
|
||||||
_e("%s keeps crashing, not restarting",
|
_e("%s keeps crashing, not restarting", svc->desc);
|
||||||
svc->desc ? : svc->cmd);
|
|
||||||
svc->block = SVC_BLOCK_CRASHING;
|
svc->block = SVC_BLOCK_CRASHING;
|
||||||
svc_set_state(svc, SVC_HALTED_STATE);
|
svc_set_state(svc, SVC_HALTED_STATE);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <lite/lite.h>
|
#include <lite/lite.h>
|
||||||
|
|
||||||
#include "finit.h"
|
#include "finit.h"
|
||||||
@@ -74,12 +75,22 @@ svc_t *svc_new(char *cmd, int id, int type)
|
|||||||
svc_t *svc = &list[i];
|
svc_t *svc = &list[i];
|
||||||
|
|
||||||
if (svc->type == SVC_TYPE_FREE) {
|
if (svc->type == SVC_TYPE_FREE) {
|
||||||
|
char *desc;
|
||||||
|
|
||||||
memset(svc, 0, sizeof(*svc));
|
memset(svc, 0, sizeof(*svc));
|
||||||
svc->type = type;
|
svc->type = type;
|
||||||
svc->job = job;
|
svc->job = job;
|
||||||
svc->id = id;
|
svc->id = id;
|
||||||
strlcpy(svc->cmd, cmd, sizeof(svc->cmd));
|
strlcpy(svc->cmd, cmd, sizeof(svc->cmd));
|
||||||
|
|
||||||
|
/* Default description, if missing */
|
||||||
|
desc = rindex(cmd, '/');
|
||||||
|
if (desc)
|
||||||
|
desc++;
|
||||||
|
else
|
||||||
|
desc = cmd;
|
||||||
|
strlcpy(svc->desc, desc, sizeof(svc->desc));
|
||||||
|
|
||||||
return svc;
|
return svc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user