Set a default description for all services

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-07-21 00:08:56 +02:00
parent fcfbd57ca8
commit a7e52914d2
2 changed files with 16 additions and 4 deletions
+5 -4
View File
@@ -475,8 +475,10 @@ int service_register(int type, char *line, time_t mtime, char *username)
}
desc = strstr(line, "-- ");
if (desc)
if (desc) {
*desc = 0;
desc += 3;
}
cmd = strtok(line, " ");
if (!cmd) {
@@ -574,7 +576,7 @@ recreate:
svc->log = log;
if (desc)
strlcpy(svc->desc, desc + 3, sizeof(svc->desc));
strlcpy(svc->desc, desc, sizeof(svc->desc));
if (username) {
char *ptr = strchr(username, ':');
@@ -759,8 +761,7 @@ restart:
svc_set_state(svc, SVC_HALTED_STATE);
} else if (cond_get_agg(svc->cond) == COND_ON) {
if (*restart_counter >= RESPAWN_MAX) {
_e("%s keeps crashing, not restarting",
svc->desc ? : svc->cmd);
_e("%s keeps crashing, not restarting", svc->desc);
svc->block = SVC_BLOCK_CRASHING;
svc_set_state(svc, SVC_HALTED_STATE);
break;
+11
View File
@@ -23,6 +23,7 @@
*/
#include <stdlib.h>
#include <strings.h>
#include <lite/lite.h>
#include "finit.h"
@@ -74,12 +75,22 @@ svc_t *svc_new(char *cmd, int id, int type)
svc_t *svc = &list[i];
if (svc->type == SVC_TYPE_FREE) {
char *desc;
memset(svc, 0, sizeof(*svc));
svc->type = type;
svc->job = job;
svc->id = id;
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;
}
}