Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swagdevops/sv-utils
Runit (sv) utils
https://github.com/swagdevops/sv-utils
alpine alpine-linux docker runit services
Last synced: 8 days ago
JSON representation
Runit (sv) utils
- Host: GitHub
- URL: https://github.com/swagdevops/sv-utils
- Owner: SwagDevOps
- License: gpl-3.0
- Created: 2018-07-21T21:09:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T18:57:56.000Z (8 months ago)
- Last Synced: 2024-11-06T20:15:12.703Z (about 2 months ago)
- Topics: alpine, alpine-linux, docker, runit, services
- Language: Ruby
- Homepage:
- Size: 176 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sv Utils
## ``svrun`` - avoid skeleton service burden
According to the [``runit-scripts``][runit-scripts]
([tarball][runit-scripts-tarball])
a minimal skeleton service (using [Alpine Linux][alpine-linux]) looks like:```sh
#!/usr/bin/env sh
# /etc/sv/skeleton/run
set -euexec 2>&1
COMMAND=daemon
USER=rootexec /usr/bin/chpst -u ${USER} ${COMMAND}
```See also:
* [Does runit support user-specific services?][runit-doc:userservices]
```sh
#!/usr/bin/env sh
# /etc/sv/skeleton/log/run
set -euSERVICE_NAME=`basename $(dirname $(dirname $(readlink -f $0)))`
LOG_DIR=/var/log/runit/${SERVICE_NAME}
USER=root
GROUP=root# Create log dir and fix owner & mode
mkdir -p ${LOG_DIR}
chown ${USER}:${GROUP} ${LOG_DIR}
chmod 700 ${LOG_DIR}exec /usr/bin/chpst -u ${USER} /usr/bin/svlogd -tt ${LOG_DIR}
```Using ``sv-utils``:
```ruby
#!/usr/bin/env svrunservice('daemon').call
``````ruby
#!/usr/bin/env svrunloggerd.call
```Moreover, options as ``:user`` and ``:group`` are supported
by ``loggerd`` and ``service`` methods, as:```ruby
service('daemon', user: :john_doe).call
`````:command``, defined in config for ``loggerd``, is used by default,
but it can be overriden (for example using [socklog][socklog]):```ruby
#!/usr/bin/env svrunloggerd(['svlogd', '-t', 'main/*'], user: :log).call
```Log directory is created, under the hood, during ``loggerd`` call.
``sv-utils`` is an attempt to bring [DRY principle][dry-definition]
to ``runit`` services creation.## See also
* [UNIX Programming by Example: Runit][sa:unix-programming-by-example-runit]
[alpine-linux]: https://alpinelinux.org/
[runit-scripts]: https://github.com/dockage/runit-scripts
[runit-scripts-tarball]: https://api.github.com/repos/dockage/runit-scripts/tarball
[socklog]: http://smarden.org/socklog/
[dry-definition]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
[runit-doc:userservices]: http://smarden.org/runit/faq.html#userservices
[sa:unix-programming-by-example-runit]: http://tammersaleh.com/posts/unix-programming-by-example-runit/