diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-06-28 04:12:58 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-06-28 04:12:58 +0200 |
commit | c2756a68401102786be343712c0c35acbd73d28d (patch) | |
tree | 64af93633ce57982937323c9a55fe1ecbf076cd1 /src/core/service.c | |
parent | 1508e85878cff23a220b2ff8d6c71418e19797de (diff) |
core: add transient units
Transient units can be created via the bus API. They are configured via
the method call parameters rather than on-disk files. They are subject
to normal GC. Transient units currently may only be created for
services (however, we will extend this), and currently only ExecStart=
and the cgroup parameters can be configured (also to be extended).
Transient units require a unique name, that previously had no
configuration file on disk.
A tool systemd-run is added that makes use of this functionality to run
arbitrary command lines as transient services:
$ systemd-run /bin/ping www.heise.de
Will cause systemd to create a new transient service and run ping in it.
Diffstat (limited to 'src/core/service.c')
-rw-r--r-- | src/core/service.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/core/service.c b/src/core/service.c index 1dcd5cf443..6f18cbf759 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -983,7 +983,7 @@ static int service_load_sysv_name(Service *s, const char *name) { assert(s); assert(name); - /* For SysV services we strip the *.sh suffixes. */ + /* For SysV services we strip the *.sh suffixes. */ if (endswith(name, ".sh.service")) return -ENOENT; @@ -1193,27 +1193,32 @@ static int service_load(Unit *u) { assert(s); /* Load a .service file */ - if ((r = unit_load_fragment(u)) < 0) + r = unit_load_fragment(u); + if (r < 0) return r; #ifdef HAVE_SYSV_COMPAT /* Load a classic init script as a fallback, if we couldn't find anything */ - if (u->load_state == UNIT_STUB) - if ((r = service_load_sysv(s)) < 0) + if (u->load_state == UNIT_STUB) { + r = service_load_sysv(s); + if (r < 0) return r; + } #endif /* Still nothing found? Then let's give up */ if (u->load_state == UNIT_STUB) return -ENOENT; - /* We were able to load something, then let's add in the - * dropin directories. */ - if ((r = unit_load_dropin(unit_follow_merge(u))) < 0) - return r; - /* This is a new unit? Then let's add in some extras */ if (u->load_state == UNIT_LOADED) { + + /* We were able to load something, then let's add in + * the dropin directories. */ + r = unit_load_dropin(u); + if (r < 0) + return r; + if (s->type == _SERVICE_TYPE_INVALID) s->type = s->bus_name ? SERVICE_DBUS : SERVICE_SIMPLE; @@ -3886,6 +3891,8 @@ const UnitVTable service_vtable = { .bus_set_property = bus_service_set_property, .bus_commit_properties = bus_service_commit_properties, + .can_transient = true, + #ifdef HAVE_SYSV_COMPAT .enumerate = service_enumerate, #endif |