Git Product home page Git Product logo

sysdweb's Introduction

sysdweb

Control systemd services through Web or REST API

Installation

From source

git clone https://github.com/ogarcia/sysdweb.git
virtualenv3 ./sysdweb-venv
source ./sysdweb-venv/bin/activate
cd sysdweb
pip install -r requirements.txt
python setup.py 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.

Run

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

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.

sysdweb

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

sysdweb -p 9080 -l 0.0.0.0

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.

[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.

/api/v1/<service>/journal/200

In the example defined above all valid enpoins are.

http://127.0.0.1:10080/api/v1/ngx/start
http://127.0.0.1:10080/api/v1/ngx/stop
http://127.0.0.1:10080/api/v1/ngx/restart
http://127.0.0.1:10080/api/v1/ngx/reload
http://127.0.0.1:10080/api/v1/ngx/reloadorrestart
http://127.0.0.1:10080/api/v1/ngx/status
http://127.0.0.1:10080/api/v1/ngx/journal
http://127.0.0.1:10080/api/v1/ngx/journal/<number>

sysdweb's People

Contributors

ogarcia avatar

Watchers

James Cloos avatar Pedro Amador Rodríguez avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.