Skip to content

Installing siptrackweb in virtualenv

Stefan Midjich edited this page Mar 7, 2018 · 39 revisions

If you find this guide unmaintained then check out the ansible roles siptrack-backend and siptrack-frontend.

How to install siptrackd in virtualenv

This how you setup your own self-hosted version of Siptrack.

This guide is last tested on Fedora 23 and CentOS 7. Here is a shorter guide for a personal dev environment.

It is assumed you have a user called siptrack, and a group called virtualenv.

$ sudo groupadd virtualenv
$ sudo useradd -r -G virtualenv siptrack

Prepare system

This differs on Debian, here are RHEL-based distros commands.

$ sudo yum install openssl-devel gcc libffi-devel mariadb mariadb-devel pwgen

Setup virtualenv

$ sudo mkdir -p /var/opt/venv
$ sudo chgrp -R virtualenv /var/opt/venv
$ sudo chmod -R 2775 /var/opt/venv

Join yourself to virtualenv and siptrack group for ease of administration. Then you can even create the virtualenv without sudo.

$ virtualenv /var/opt/venv/siptrack

Enter virtualenv for the rest of the installation.

$ . /var/opt/venv/siptrack/bin/activate

Install dependencies in virtualenv.

$ pip install textile Twisted pyOpenSSL python-ldap Django gunicorn Whoosh pycrypto

Install siptrackd and siptrackweb

Clone git repos.

$ sudo mkdir /var/opt/siptrack
$ sudo chgrp -R virtualenv /var/opt/siptrack
$ sudo chmod -R 2775 /var/opt/siptrack
$ cd /var/opt/siptrack
$ git clone # Background API daemon
$ git clone # Web GUI
$ git clone # Client tools and library

Enter the cloned git repository and install.

$ cd siptrack
$ python install
$ cd ..

$ cd siptrackd
$ python install
$ cd ..

$ cd siptrackweb
$ python install
$ cd ..

Configure siptrackd

Here is an example systemd unit for siptrackd, change paths to correspond with your install. Set ConditionPathExists to wherever you installed siptrackd.

Description=Siptrackd - Inventory management backend server

ExecStart=/bin/bash -c "source $SIPTRACKD_VENVDIR/bin/activate; $SIPTRACKD_VENVDIR/bin/siptrackd $SIPTRACKD_ARGS"


Make sure to also create the EnvironmentFile /etc/sysconfig/siptrackd with the virtualenv path.

SIPTRACKD_ARGS=-l - -b stsqlite -s /etc/siptrackd_storage.cfg --searcher=whoosh --searcher-args=/tmp/st-whoosh

Also copy the sample storage configuration from /var/opt/siptrack/siptrackd/storage.cfg into /etc as shown in SIPTRACKD_ARGS above. Make sure its permissions aren't readable by world.

Enable and start in systemd.

$ sudo systemctl daemon-reload
$ sudo systemctl enable siptrackd
$ sudo systemctl start siptrackd

Follow logs with journalctl -flau siptrackd.

Configure siptrackweb

$ sudo mkdir /var/www/siptrackweb
$ sudo chown -R siptrack:virtualenv /var/www/siptrackweb
$ sudo chmod -R 2775 /var/www/siptrackweb
$ cd /var/www/siptrackweb
$ django-admin startproject stweb
$ cd stweb

Open the file stweb/ and edit the following values.

SIPTRACK_SERVER = 'localhost'
DATABASE_NAME = 'siptrackweb'
TIME_ZONE = 'Europe/Copenhagen'

# Application definition


Also remove the line about CSRF middleware from MIDDLEWARE_CLASSES.


Then edit stweb/ so it contains the following.

from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
    url(r'', include('siptrackweb.urls')),

Now generate the database and an admin user.

$ python migrate

Install supervisord and configure gunicorn

Install supervisord on CentOS.

$ sudo yum install supervisor

Enable and start supervisor service on CentOS.

$ sudo systemctl enable supervisord
$ sudo systemctl start supervisord

Configure gunicorn in supervisor

Create the file /etc/supervisor.d/siptrackweb.ini on CentOS. File path might differ on Debian-based systems.

command=/var/opt/venv/siptrack/bin/gunicorn stweb.wsgi --workers 3 --log-level DEBUG --bind localhost:8080

Start siptrackweb.

$ sudo supervisorctl start siptrackweb

Configure nginx

Copy static files into /var/www.

$ sudo cp -r /var/opt/venv/siptrack/lib/python2.7/site-packages/siptrackweb/static /var/www/siptrackweb/

Here is a sample nginx configuration.

server {
  listen 80;
  server_name siptrack.localhost;

  location / {
    add_header X-Clacks-Overhead "GNU Terry Pratchett";
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    location /static/ {
      alias /var/www/siptrackweb/static/;

    # if using ssl set this
    # proxy_set_header X-Forwarded-Proto https;

    if (!-f $request_filename) {
      proxy_pass http://localhost:8080;

Restart nginx and browse to the domain you configured for siptrack, login with admin:admin.


Enable httpd service to connect to the backend.

$ sudo setsebool -P httpd_can_network_connect=on


Note on reinstalling, if you get weird permission errors that you can't explain it might be good to just start over. Shutdown all services and delete all dirs.

$ cd /var/opt/siptrack
$ sudo systemctl stop nginx && sudo systemctl stop supervisord && sudo systemctl stop siptrackd
$ sudo rm -rf siptrackweb siptrackd /var/www/siptrackweb /var/opt/venv

And do the guide over again but skipping the user and group creation.

Whoosh locking Exception

This might happen at startup of Siptrackd but just restart the service and it should be resolved.