Browse Source

introduce systemd-unit for indexer

The indexer is launched by systemd when the crawler finishes.
When launched through the unit, the output to stdout is
redirected to systemd-journald. There's no need for additional
file output, thus it has been removed.

Signed-off-by: Natalie Pendragon <natpen@natpen.net>
master
René Wagner 9 months ago
committed by Natalie Pendragon
parent
commit
44812ee8b5
  1. 5
      README.md
  2. 3
      infra/gus-crawl.service
  3. 13
      infra/gus-index.service
  4. 10
      logging.ini

5
README.md

@ -36,14 +36,13 @@ Now you'll have created `index.new` directory, rename it to `index`.
2. Run: `poetry run build_index`
3. Restart frontend
### Running the crawl in production with systemd
### Running the crawl & indexer in production with systemd
1. update `infra/gus-crawl.service` to match your needs (directory, user)
1. update `infra/gus-crawl.service` & `infra/gus-index.service` to match your needs (directory, user)
2. update `infra/gus-crawl.timer` to match your needs (OnCalendar definition)
3. copy both files to `/etc/systemd/system/`
4. run `systemctl enable gus-crawl.timer` & `systemctl start gus-crawl.timer` to start the timer
## Running the test suite
Run: `poetry run pytest`

3
infra/gus-crawl.service

@ -1,4 +1,4 @@
# /etc/systemd/system/gus.service
# /etc/systemd/system/gus-crawl.service
[Unit]
Description=Gemini Universal Search - Crawler
@ -10,3 +10,4 @@ Type=oneshot
WorkingDirectory=/home/gus/code/gus
Environment="PYTHONUNBUFFERED=1"
ExecStart=/home/gus/.poetry/bin/poetry run crawl
ExecStopPost=systemctl start gus-index

13
infra/gus-index.service

@ -0,0 +1,13 @@
# /etc/systemd/system/gus-index.service
[Unit]
Description=Gemini Universal Search - Indexer
[Service]
User=gus
Group=gus
Type=oneshot
WorkingDirectory=/home/gus/code/gus
Environment="PYTHONUNBUFFERED=1"
ExecStart=/home/gus/.poetry/bin/poetry run build_index
ExecStopPost=systemctl restart gus

10
logging.ini

@ -2,14 +2,14 @@
keys=root
[handlers]
keys=consoleHandler,fileHandler
keys=consoleHandler
[formatters]
keys=plain
[logger_root]
level=NOTSET
handlers=consoleHandler,fileHandler
handlers=consoleHandler
[handler_consoleHandler]
class=StreamHandler
@ -17,11 +17,5 @@ level=INFO
formatter=plain
args=(sys.stdout,)
[handler_fileHandler]
class=FileHandler
level=DEBUG
formatter=plain
args=("gus.log",)
[formatter_plain]
format=%(asctime)s %(module)-8s %(levelname)-8s %(message)s

Loading…
Cancel
Save