SvcD class and "svcd" command to run persistent service programmes.
This provides the features one wants from a daemon for arbitrary commands providing a service:
- process id (pid) files for both svcd and the service command
- filesystem visible status (command running, service enabled)
via
cs.app.flag <https://pypi.org/project/cs.app.flag/>_ - command restart if the command exits
- command control (stop, restart, disable)
via
cs.app.flag <https://pypi.org/project/cs.app.flag/>_ - test function to monitor for service viability; if the test function fails, do not run the service. This typically monitors something like network routing (suspend service while laptop offline) or a ping (suspend ssh tunnel while target does not answer pings).
- signature function to monitor for service restart; if the signature changes, restart the service. This typically monitors something like file contents (restart service on configuration change) or network routing (restart ssh tunnel on network change)
- callbacks for service command start and end, for example to display desktop notifications
I use this to run persistent ssh port forwards and a small collection of other personal services. I have convenient shell commands to look up service status and to start/stop/restart services.
See cs.app.portfwd <https://pypi.org/project/cs.app.portfwd/>_
which I use to manage my ssh tunnels;
it is a single Python programme
running multiple ssh commands, each via its own SvcD instance.
Function main(argv=None)
Command line main programme.
Class SvcD
MRO: cs.app.flag.FlaggedMixin
A process based service.
SvcD.__init__(self, argv, name=None, environ=None, flags=None, group_name=None, pidfile=None, sig_func=None, test_flags=None, test_func=None, test_rate=None, restart_delay=None, once=False, quiet=False, trace=False, on_spawn=None, on_reap=None)
Initialise the SvcD.
Parameters:
* `argv`: command to run as a subprocess.
* `flags`: a cs.app.flag.Flags -like object, default None;
if None the default flags will be used.
* `group_name`: alert group name, default "SVCD " + `name`.
* `pidfile`: path to pid file, default $VARRUN/{name}.pid.
* `sig_func`: signature function to compute a string which
causes a restart if it changes
* `test_flags`: map of {flagname: truthiness} which should
be monitored at test time; truthy flags must be true and
untruthy flags must be false
* `test_func`: test function with must return true if the comannd can run
* `test_rate`: frequency of tests, default TEST_RATE
* `restart_delay`: delay before start of an exiting command,
default RESTART_DELAY
* `once`: if true, run the command only once
* `quiet`: if true, do not issue alerts
* `trace`: trace actions, default False
* `on_spawn`: to be called after a new subprocess is spawned
* `on_reap`: to be called after a subprocess is reaped
Metadata
Release files for cs.app.svcd 20190602
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cs.app.svcd-20190602.tar.gz | 7.8 kB | Without provenance | Details for cs.app.svcd-20190602.tar.gz |
Release files / cs.app.svcd-20190602.tar.gz
| Download URL | cs.app.svcd-20190602.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de00eaf47e3668e7c48591aa2761c5b356c42ff20dcc6d7273e6ebdd544dfff2
|
|
BLAKE2b-256 checksum How to use checksums |
8952bf34a5e564b174a97db9281647b46de32465b9e87281c2f4342f9b1af10c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for cs.app.svcd 20190602
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.