Component | Location |
---|---|
Frontend & backend (Flask webapp, unprivileged) | https://github.com/SRCF/control-panel |
Job runner (Postgres listener, root-privileged) | srcf-scripts Python library: srcf.controllib.job_runner |
Job definitions | srcf-scripts Python library: srcf.controllib.jobs |
Each job has an environment
associated with it. Jobs created by a control panel frontend with a given environment tag will only be picked up by a job runner using the corresponding tag. The live system (https://control.srcf.net + systemd service runner) use live
as their tag.
At most one runner per environment can run, managed by PostgreSQL advisory locks.
- Set up a !GitHub account, configure SSH keys, be granted access to the SRCF group etc.
- Clone the control panel repository into your own dev folder:
git clone [email protected]:SRCF/control-panel.git ~srcf-admin/control-hackday-$USER
- Choose a random high-numbered port to run your frontend on, e.g.:
export PORT=54321 # but choose something better
- Add a rewrite rule to
/public/societies/srcf-admin/public_html/.htaccess
:
cat >>/public/societies/srcf-admin/public_html/.htaccess_ <<EOF
RewriteRule "^control-$USER/(.*)$" "http://localhost:$PORT/\$1" [P,QSA]
EOF
- Start your dev server on sinkhole (ssh to
webserver.srcf.net
):
cd ~srcf-admin/control-hackday-$USER
sudo -Hu srcf-admin env SRCF_JOB_QUEUE=$USER wsgi-proxy-run control.webapp:app $PORT \
--debug --https --prefix /control-$USER --host srcf-admin.soc.srcf.net
- Find your dev server at
https://srcf-admin.soc.srcf.net/control-$USER/
(the trailing slash is important)
-
Clone the srcf-scripts SVN repository in your -adm account, if you haven't already.
-
Prioritise the local Python lib over
/usr/local
($PYTHONPATH
,.pth
file in~./local
packages etc.). -
Start your job runner on pip:
sudo env SRCF_JOB_QUEUE=$NON_ADM_USER python3 -m srcf.controllib.job_runner
cd ~srcf-admin/control
git pull
uwsgi
on sinkhole will automatically restart the site when .git/HEAD
changes.
On pip:
sudo update-usr-local
sudo systemctl restart control-panel-job-runner.service
There is a basic Dockerfile
to ensure dependencies are tracked and to assist (some forms of) testing and local development.
To build:
$ docker build --tag srcf/control .
Actually running the service locally via Docker is currently experimental at best, and looks something like the following:
- Modify
run.py
to passdebug=False
to theapp.run
call - docker run --tty --interactive --env FLASK_TRUSTED_HOSTS=localhost --env FLASK_SECRET_KEY=not-a-secret --env DOMAIN_WEB=localhost --env FLASK_ENV=development -p 5000:5000 srcf/control
- Point your browser at http://localhost:5000/