Package Exports
- @systemd-js/ctl
- @systemd-js/ctl/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@systemd-js/ctl) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@systemd-js/ctl
Control over units. Interface to systemctl. At the moment this lack proper error handling.
Installation
yarn add @systemd-js/ctlExamples
State manipulation of existing service.
import { Ctl } from "@systemd-js/ctl";
const ctl = new Ctl("test.service");
ctl.isActive();
ctl.isEnabled();
ctl.write();
ctl.disable();
ctl.enable();
ctl.stop();
ctl.start();
ctl.restart();Creation of new service "example.service"
import { Service } from "@systemd-js/config";
import { Ctl } from "@systemd-js/ctl";
const service = new Service();
service
.getUnitSection()
.setDescription("This is a example unit");
service
.getInstallSection()
.setWantedBy("multi-user.target");
service
.getServiceSection()
.setType("simple")
.setExecStart("/usr/bin/echo 'Hello World'");
const ctl = new Ctl("example", service);
ctl.write();
ctl.enable();
ctl.start();In addition to Ctl class, package expose functions to call systemctl directly.
import { restart, start, stop } from "@systemd-js/ctl";
write("example.service");
stop("example.service");
start("example.service");
enable("example.service");
disable("example.service");
reload("example.service");
restart("example.service");
isActive("example.service");
isEnabled("example.service");
daemonReload();