Skip to content

Development Quick Start

Kamila Součková edited this page Jul 14, 2018 · 5 revisions

If you're reading this, you are probably thinking about contributing to stalky. If that's the case, hooray and welcome and you're awesome! 👍

Requirements

  • python3 for the server
    • The easiest way to get Python 3 is to install it using your package manager, e.g. apt-get install python3. Versions >= 3.5 are tested, 3.4 probably works too.
  • pipenv, because pipenv is awesome. Install using pip3 install --user pipenv or something, see docs.
  • If you won't ever change the web UI, including the bits that send requests to the server, you can do without elm and just use the pre-compiled bundle.js as mentioned in Installation. Otherwise see below.

Working on the server

The server is split into two parts: this repo pulls it all together, while csvtsdb provides the CSV-backed database. This separation will make more sense in the future. Right now it's kinda stupid actually.

It's just standard python+twisted, nothing special here. server.py is the entry point. Note that at the moment, there is no auto-reload, so you have to manually restart the server when you make changes. (TODO I should fix that!)

You can use make run to install dependencies and run server.py.

Pipenv is used for managing dependencies and everything.

Working on the web UI

It might be convenient to cd webui/ and use the Makefile in there instead of the top-level one. It has some extra stuff.

Installing elm

  • The easiest way to get elm is to install node (on recent-ish ubuntu, apt-get install nodejs gives you a usable version for our purposes). With npm available, the Makefile will set up stuff needed to compile the web UI -- just run make build.
  • If you want to use the devserver with auto-reload, you need to install elm-live, which should be installed globally: sudo npm install -g elm-live.
  • If you don't want to or can't install elm via npm (e.g. on FreeBSD this doesn't work), you could in theory compile elm-lang from source. However, this is probably awful and I never tested that.

Live-reloading dev server

sudo npm install -g elm-live, then cd webui/; make live in a new terminal (you need this running separately from the server, as the server proxies to this). Note that you need port 8000 free, as otherwise elm will use the next free port, which breaks the proxying.

Note that the dev server is at /dev and / still has the normal server, so make sure to open http://localhost:8500/dev when using this.

⚠️ Important: Committing the pre-built bundle.js

In order to simplify deployment, a pre-built bundle.js is included in the repo. Therefore, if you make any changes to the web UI, you must make sure to commit the correct thing! The easiest way to ensure that is to add a git pre-commit hook: run make dev-git-hooks to set up a pre-commit hook which builds and adds the file on commit.