mirror of
https://github.com/troglobit/finit.git
synced 2026-10-16 10:39:35 +00:00
Usability, a servivce stopped by a user is stopped, not blocked
The generic term for a non-running service is blocked, but a service may be blocked for several different reasons. When a user stops a service with `initctl stop` the intuitive expected output from `initctl show` is "stopped" not "blocked". When the user later restarts the service with `initctl start` it may of course be blocked due to wrong runlevel or a missing condition. As can be expected from the service's configuration. The rest of the patch refactors the internal API names a bit to reflect this change. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
516dbcc512
commit
260335a19f
4 files changed
+14
-12
No files matched your search
+3
-2
@@ -14,8 +14,9 @@ state.
|
||||
The current state depends on the two following conditions:
|
||||
|
||||
* `E`: Service enabled. In order for `E` to be satisfied, the service
|
||||
must be allowed to run in the current runlevel and must not be
|
||||
blocked. A service may be blocked for several reasons:
|
||||
must be allowed to run in the current runlevel and not be stopped.
|
||||
|
||||
A service may be stopped, or blocked, for several reasons:
|
||||
|
||||
- The user has manually stopped the service using `initctl stop JOB`
|
||||
- The program exits immediately. I.e. keeps crashing (make sure to use
|
||||
|
||||
@@ -49,23 +49,23 @@ static int call(int (*action)(svc_t *), char *buf, size_t len)
|
||||
return svc_parse_jobstr(buf, len, action, NULL);
|
||||
}
|
||||
|
||||
static int service_block(svc_t *svc)
|
||||
static int service_stop(svc_t *svc)
|
||||
{
|
||||
if (!svc)
|
||||
return 1;
|
||||
|
||||
svc_block(svc);
|
||||
svc_stop(svc);
|
||||
service_step(svc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int service_unblock(svc_t *svc)
|
||||
static int service_start(svc_t *svc)
|
||||
{
|
||||
if (!svc)
|
||||
return 1;
|
||||
|
||||
svc_unblock(svc);
|
||||
svc_start(svc);
|
||||
service_step(svc);
|
||||
|
||||
return 0;
|
||||
@@ -82,8 +82,8 @@ static int service_restart(svc_t *svc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_start (char *buf, size_t len) { return call(service_unblock, buf, len); }
|
||||
static int do_pause (char *buf, size_t len) { return call(service_block, buf, len); }
|
||||
static int do_start (char *buf, size_t len) { return call(service_start, buf, len); }
|
||||
static int do_stop (char *buf, size_t len) { return call(service_stop, buf, len); }
|
||||
static int do_restart(char *buf, size_t len) { return call(service_restart, buf, len); }
|
||||
|
||||
#ifdef INETD_ENABLED
|
||||
@@ -240,7 +240,7 @@ static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
|
||||
break;
|
||||
|
||||
case INIT_CMD_STOP_SVC:
|
||||
result = do_pause(rq.data, sizeof(rq.data));
|
||||
result = do_stop(rq.data, sizeof(rq.data));
|
||||
break;
|
||||
|
||||
case INIT_CMD_RESTART_SVC:
|
||||
|
||||
@@ -480,7 +480,7 @@ char *svc_status(svc_t *svc)
|
||||
return "crashed";
|
||||
|
||||
case SVC_BLOCK_USER:
|
||||
return "blocked";
|
||||
return "stopped";
|
||||
|
||||
case SVC_BLOCK_BUSY:
|
||||
return "busy";
|
||||
|
||||
@@ -92,7 +92,7 @@ typedef struct svc {
|
||||
int starting; /* ... waiting for pidfile to be re-asserted */
|
||||
int runlevels;
|
||||
int sighup; /* This service supports SIGHUP :) */
|
||||
svc_block_t block; /* Reason that this service is currently blocked */
|
||||
svc_block_t block; /* Reason that this service is currently stopped */
|
||||
char cond[MAX_ARG_LEN];
|
||||
|
||||
/* Incremented for each restart by service monitor. */
|
||||
@@ -192,7 +192,8 @@ static inline int svc_is_daemon (svc_t *svc) { return svc && SVC_TYPE_SERVICE
|
||||
static inline int svc_is_blocked (svc_t *svc) { return svc->block != SVC_BLOCK_NONE; }
|
||||
static inline int svc_is_busy (svc_t *svc) { return svc->block == SVC_BLOCK_BUSY; }
|
||||
static inline void svc_unblock (svc_t *svc) { svc->block = SVC_BLOCK_NONE; }
|
||||
static inline void svc_block (svc_t *svc) { svc->block = SVC_BLOCK_USER; }
|
||||
#define svc_start(svc) svc_unblock(svc)
|
||||
static inline void svc_stop (svc_t *svc) { svc->block = SVC_BLOCK_USER; }
|
||||
static inline void svc_busy (svc_t *svc) { svc->block = SVC_BLOCK_BUSY; }
|
||||
static inline void svc_missing (svc_t *svc) { svc->block = SVC_BLOCK_MISSING; }
|
||||
static inline void svc_restarting (svc_t *svc) { svc->block = SVC_BLOCK_RESTARTING; }
|
||||
|
||||
Reference in new issue
Block a user