Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Control systemd services through Web or REST API

Project description

# sysdweb
Control systemd services through Web or REST API

## Installation

### From source

git clone
virtualenv3 ./sysdweb-venv
source ./sysdweb-venv/bin/activate
cd sysdweb
pip install -r requirements.txt
python install

### From pypi

virtualenv3 ./sysdweb-venv
source ./sysdweb-venv/bin/activate
pip install sysdweb

### For Arch Linux users

Arch Linux users can install sysdweb from [AUR][1].

## Run

First take a look to `sysdweb.conf` file to configure sysdweb. Is self

You can place `sysdweb.conf` in `/etc` for system, in user home
`~/.config/sysdweb/sysdweb.conf` or in same directory where you run sysdweb.

Once you have configured sysdweb, simply run.


By default sysdweb listen in 10080 port to, you can change listen
port and address with `-p` and `-l` or via environment variables.

sysdweb -p 9080 -l

Current config environment variables are the following.

| Variable | Description |
| --- | --- |
| `SYSDWEB_CONFIG` | Config file location |
| `SYSDWEB_HOST` | Listen address |
| `SYSDWEB_PORT` | Listen port |
| `SYSDWEB_LOGLEVEL` | Log level, effective values are `WARNING`, `INFO` and `DEBUG` |

## API

You can control configured services via REST API, for example, with curl.

The API endpoint is `/api/v1/<service>/<action>`, always `GET` and response
a json with following format.

"<action>": "<result>"

The `<service>` tag is defined in config file and match with section label.
For example, in following config, the service would be `ngx`.

title = Nginx
unit = nginx.service

The posible `<actions>` are.

* start
* stop
* restart
* reload
* reloadorrestart
* status
* journal

All actions (except `status` and `journal`) return as result `OK` if can
communicate with DBUS or `Fail` if any error occurs.

For `status` action, the posible responses are.

* active (started unit)
* reloading
* inactive (stopped unit)
* failed (stopped unit)
* activating
* deactivating
* not-found (for inexistent unit)

By default `/api/v1/<service>/journal` returns 100 tail lines of journal
file of `<service>` unit. You can specify the number of lines by this way.


In the example defined above all valid enpoins are.



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sysdweb, version 1.1.3
Filename, size File type Python version Upload date Hashes
Filename, size sysdweb-1.1.3.tar.gz (222.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page