Skip to content

Latest commit

 

History

History
177 lines (149 loc) · 4.17 KB

README.md

File metadata and controls

177 lines (149 loc) · 4.17 KB

Spacestatus Server

Flask/Connexion based web application providing a hackspace status website and JSON frontend for spaceAPI.

Plugins (to post status change)

  • Mastodon (API permissions: read:accounts, write:statuses)
  • Matrix
  • Twitter

Known limitations

  • Application not usable in multiprocess environment (gunicorn will work in threading mode)

Provided endpoints

GET

Endpoint Description
/ rendered template from templates/home.html
/status.json Hackspace API JSON file
/status-minimal.json JSON file with state and state icon
/static/{images,js,css}/{filename} Files from static folder

PUT

Endpoint Description Example
/api/v1/status Set status

Temperature Sensor could also be added.
{
  "sensors": {
    "people_now_present": [{
      "value": 0,
      "names": []
    }]
  },
  "state": {
    "open": false,
    "lastchange": 1612387891,
    "message": "No devices connected"
  }
}
/api/v1/sensors/temperature Set temperature sensors
{
  "sensors": {
    "temperature": [
      { "value": 12.81, "unit": "°C", "location": "Hackspace" },
      { "value": -6.44, "unit": "°C", "location": "Outside" }
    ]
  }
}

Dependencies

System (Debian-related)

  • git
  • python3 (>=3.7, tested with 3.11)
  • python3-venv

Python modules

Installation

You should install this application using a dedicated user.

After your installation spacestatus-server serves on port 5000 on all interfaces. Configure your preferred http proxy (apache, nginx, traefik, ...) to allow access via http/https.

System requirements on Debian

  1. Install system requirements

    sudo apt-get update
    sudo apt-get install python3-venv git
  2. Create spacestatus user

    sudo useradd --comment "Spacestatus" --create-home  --user-group spacestatus

Spacestatus server

  1. Change to spacestatus user

    sudo su - spacestatus
  2. Clone repository

    git clone https://github.com/Bytespeicher/spacestatus-server
  3. Initialize virtual environment

    python3 -m venv virtualenv3
  4. Install python requirements in virtual environment

    . virtualenv3/bin/activate
    pip3 install wheel
    pip3 install -r spacestatus-server/requirements.txt
    pip3 install gunicorn
    deactivate
  5. Copy example configuration files

    cd ~/spacestatus-server
    cp config/config.example.yaml config/config.yaml
    cp config/apidata/status.example.org.json config/apidata/status.your-domain.org.json
  6. Adjust configuration file config/config.yaml

  7. Adjust space api json file config/apidata/status.your-domain.org.json

Install systemd unit

  1. Copy systemd unit file

    sudo cp /home/spacestatus/spacestatus-server/contrib/spacestatus-server.service /etc/systemd/system/spacestatus-server.service
  2. Adapt /etc/systemd/system/spacestatus-server.service if service should not listen on all interfaces

  3. Reload systemd daemon to reload unit file and start and enable service

    sudo systemctl daemon-reload
    sudo systemctl enable spacestatus-server.service --now

Update

Spacestatus server

  1. Change to spacestatus user

    sudo su - spacestatus
  2. Update repository

    cd spacestatus-server
    git pull
  3. Update virtual environment

    cd
    python3 -m venv --upgrade virtualenv3
  4. Update python requirements in virtual environment

    cd
    . virtualenv3/bin/activate
    pip3 install --upgrade wheel
    pip3 install --upgrade -r spacestatus-server/requirements.txt
    pip3 install --upgrade gunicorn
    deactivate
  5. Adjust configuration file config/config.yaml

  6. Restart systemd daemon

    sudo systemctl restart spacestatus-server.service