mirror of
https://github.com/troglobit/finit.git
synced 2026-11-21 19:51:46 +00:00
Improve service state machine debug messages
In addition to logging state transitions, also log the parameters that might trigger a transition.
This commit is contained in:
1 parent
02eb68f46c
commit
171d611b14
3 files changed
+17
-8
No files matched your search
@@ -787,15 +787,15 @@ void service_step(svc_t *svc)
|
|||||||
svc_cmd_t enabled;
|
svc_cmd_t enabled;
|
||||||
svc_state_t old_state;
|
svc_state_t old_state;
|
||||||
cond_state_t cond;
|
cond_state_t cond;
|
||||||
char *old_status = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
old_state = *state;
|
old_state = *state;
|
||||||
enabled = service_enabled(svc);
|
enabled = service_enabled(svc);
|
||||||
|
|
||||||
if (debug)
|
_d("%20s(%4d): %8s %3sabled/%-7s cond:%-4s", svc->cmd, svc->pid,
|
||||||
old_status = strdup(svc_status(svc));
|
svc_status(svc), enabled? "en" : "dis", svc_dirtystr(svc),
|
||||||
|
condstr(cond_get_agg(svc->cond)));
|
||||||
|
|
||||||
switch(*state) {
|
switch(*state) {
|
||||||
case SVC_HALTED_STATE:
|
case SVC_HALTED_STATE:
|
||||||
@@ -937,11 +937,7 @@ restart:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*state != old_state) {
|
if (*state != old_state) {
|
||||||
if (debug) {
|
_d("%20s(%4d): -> %8s", svc->cmd, svc->pid, svc_status(svc));
|
||||||
_d("%-20.20s %s -> %s", svc->cmd,
|
|
||||||
old_status, svc_status(svc));
|
|
||||||
free(old_status);
|
|
||||||
}
|
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -434,6 +434,18 @@ char *svc_status(svc_t *svc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *svc_dirtystr(svc_t *svc)
|
||||||
|
{
|
||||||
|
if (svc_is_removed(svc))
|
||||||
|
return "removed";
|
||||||
|
else if (svc_is_updated(svc))
|
||||||
|
return "updated";
|
||||||
|
else if (svc_is_changed(svc))
|
||||||
|
return "UNKNOWN";
|
||||||
|
else
|
||||||
|
return "clean";
|
||||||
|
}
|
||||||
|
|
||||||
/* Same base service, return unique ID */
|
/* Same base service, return unique ID */
|
||||||
int svc_next_id(char *cmd)
|
int svc_next_id(char *cmd)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ static inline int svc_is_dynamic(svc_t *svc) { return svc && 0 != svc->mtime; }
|
|||||||
static inline int svc_is_removed(svc_t *svc) { return svc && -1 == svc->dirty; }
|
static inline int svc_is_removed(svc_t *svc) { return svc && -1 == svc->dirty; }
|
||||||
static inline int svc_is_changed(svc_t *svc) { return svc && 0 != svc->dirty; }
|
static inline int svc_is_changed(svc_t *svc) { return svc && 0 != svc->dirty; }
|
||||||
static inline int svc_is_updated(svc_t *svc) { return svc && 1 == svc->dirty; }
|
static inline int svc_is_updated(svc_t *svc) { return svc && 1 == svc->dirty; }
|
||||||
|
const char *svc_dirtystr (svc_t *svc);
|
||||||
|
|
||||||
static inline int svc_is_inetd (svc_t *svc) { return svc && SVC_TYPE_INETD == svc->type; }
|
static inline int svc_is_inetd (svc_t *svc) { return svc && SVC_TYPE_INETD == svc->type; }
|
||||||
static inline int svc_is_daemon (svc_t *svc) { return svc && SVC_TYPE_SERVICE == svc->type; }
|
static inline int svc_is_daemon (svc_t *svc) { return svc && SVC_TYPE_SERVICE == svc->type; }
|
||||||
|
|||||||
Reference in new issue
Block a user