diff --git a/README.md b/README.md new file mode 100644 index 0000000..59d70ad --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# arec-watcher + +A daemon program that watches an upload directory for new completed uploads +from arec recorders and sends a notification to play-api to initiate +processing of the uploaded presentation. + +## Setup + + * Clone the repo to `/opt/arec-watcher` + * Create a python venv in the project root: `python3 -m venv env` + (other names are possible but will cause some minor headaches) + * Activate the environment: `source env/bin/activate` + * Install dependencies: `pip install -r requirements.txt` + +For development: + * Run the program: `python3 -m watcher` + +For production: + * Copy `config.ini.example`to `config.ini` and set the proper parameters + * Create an `arec-watcher` user + * Install the systemd unit file: + `sudo cp arec-watcher.service /etc/systemd/system/` + * Activate the service: `sudo systemctl enable arec-watcher.service` + * Run the service: `sudo systemctl start arec-watcher.service` diff --git a/arec-watcher.service b/arec-watcher.service new file mode 100644 index 0000000..ca35f86 --- /dev/null +++ b/arec-watcher.service @@ -0,0 +1,14 @@ +[Unit] +Description = arec recording upload monitoring daemon +After = multi-user.target + +[Service] +Type = exec +Restart = on-failure +ExecStart = /opt/arec-watcher/env/bin/python3 -m watcher +WorkingDirectory = /opt/arec-watcher +User = arec-watcher +SyslogIdentifier = arec-watcher + +[Install] +WantedBy = multi-user.target diff --git a/config.ini.example b/config.ini.example index a0f2adf..b17a7d7 100644 --- a/config.ini.example +++ b/config.ini.example @@ -1,6 +1,21 @@ [arec-watcher] watchdir = /some/uploaddir/to/watch -notify_url = https://example.com/notify +notify_url = https://example.com/post/notify [logging] -level = DEBUG +# Logging settings. This entire section is optional. +# see https://docs.python.org/3.9/library/logging.html for details + +## What log messages are shown on stderr. +## Defaults to ERROR if omitted. +## For the spammiest logging, use the number 5 here. +## Beware that this can log multiple gigabytes per hour. +log_level = DEBUG + +## Mail settings for emailing log messages. +## If mail_level is not set, no emails will be sent. +## If mail_level is present, all other mail_* fields must be configured. +mail_level = ERROR +mail_from = messages@example.com +mail_to = admin@example.com +mail_subject = arec-watcher has encountered an error