Skip to content

Commit

Permalink
pulling in projectr service content from "main" branch
Browse files Browse the repository at this point in the history
  • Loading branch information
adkinsrs committed Sep 6, 2024
1 parent c79f52f commit f1cc467
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/setup_rabbitmq.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ As root, I would create a file in `/var/log/gEAR_queue` named `<service>.log` wh

## Running a particular consumer

NOTE: This is automatically handled in the projectr_consumer system.d service file

First, make sure a directory is present under /var/log/gEAR_queue (you may have to create this as root). If you are not going to run the consumer listener as root, ensure the user has the same group-write privileges as the directory.

The consumer scripts are stored at `<root>/listeners/<files>`. Let it run in the background (preferably with `nohup`)
Expand Down
17 changes: 17 additions & 0 deletions systemd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# system.d files

These are service files to place in `/etc/systemd/system/` to run as a service.

The "@" in the service file name indicates that this file is a template file. You can spawn off workers off of this template by appending numbers after the "@". For instance, if you have a "[email protected]" template, you can spawn off "[email protected]", "[email protected]", etc. You can also just use the ".target" file to group all these workers together as a service rather than having to start each indiviudally. See https://www.stevenrombauts.be/2019/01/run-multiple-instances-of-the-same-systemd-unit/ for more info on all this.

## Non-persisting start

To start the service run `sudo systemctl start <service_filename>`. If any changes are made to the service run `sudo systemctl daemon-reload`, and then run the "start" command again. This will not persist during a reboot.

## Reboot-persisting start

To start a service that persists during a reboot, run `sudo systemctl enable <service_filename>`. After enabling, you will still need to run the `systemctl start` command to start on this boot session.

## Notes

* For a service that is supposed to persist, like a RabbitMQ consumer, use Service->Type=Simple. If you use Type->Forking, I believe systemctl will forever wait for the forked process to exit and return to command line.
6 changes: 6 additions & 0 deletions systemd/projectr-consumer.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=ProjectR Consumer Workers
[email protected] [email protected] [email protected]

[Install]
WantedBy=multi-user.target
17 changes: 17 additions & 0 deletions systemd/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description="ProjectR Consumer for RabbitMQ - #%i"
Documentation=https://github.com/IGS/gEAR/blob/main/docs/setup_rabbitmq.md
After=rabbitmq-server.service

[Service]
Type=simple
Environment=APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/opt/bin/python3 /home/jorvis/git/gEAR/listeners/projectr_consumer.py
KillMode=mixed
PrivateTmp=true
Restart=always
RestartSec=2s
StartLimitIntervalSec=0

[Install]
WantedBy=multi-user.target

0 comments on commit f1cc467

Please sign in to comment.