#1 2026-01-09 07:25:57

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 500

running agl and mormot in unix - simple ways of running

Trying to run an agl derived app and two mormot2 services in linux I come to solutions that work in simple way. I leave it here for comments and as it could useful for someone else.

I found that using systemd is an easy way to keep running mormot services and agl.
A working /etc/systemd/system/yoursystemdservice.service without troubles and special care example of systemd is and can be used for agl and mormot services:

[Unit]
Description=Your mormot service
After=network.target yourdb.service
Wants=network-online.target

[Service]
Type=simple
User=youruser
Group=yourgroup
UMask=0007
WorkingDirectory=/usr/local/bin/yourdir
ExecStart=/usr/local/bin/yourdir/yourserviceexecutable -c
TimeoutSec=40
Restart=on-failure
RestartSec=10s
TimeoutStopSec=20
KillMode=mixed
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target

enable with systemctl enable yoursystemdservice
if agl does not run as root (the proposed way for security reasons), the start/stop operations to other services is not allowed
A solution to that is to define which commands to use in sudo with: visudo -f /etc/sudoers.d/yourappname and enter

# Allow youruser to manage agl service
youruser ALL=(ALL) NOPASSWD: /bin/systemctl start yoursystemdservice
youruser ALL=(ALL) NOPASSWD: /bin/systemctl stop yoursystemdservice
youruser ALL=(ALL) NOPASSWD: /bin/systemctl restart yoursystemdservice
youruser ALL=(ALL) NOPASSWD: /bin/systemctl status yoursystemdservice
youruser ALL=(ALL) NOPASSWD: /bin/systemctl is-active yoursystemdservice
youruser ALL=(ALL) NOPASSWD: /usr/bin/journalctl -u yoursystemdservice*

now in agl's start/stop operations you should use:
exec:/bin/sudo /bin/systemctl start yoursystemdservice
exec:/bin/sudo /bin/systemctl stop yoursystemdservice

Thanks again to ab and all for this excellent framework

Offline

#2 Yesterday 11:03:03

PierceNg
Member
From: Singapore
Registered: 2023-01-29
Posts: 12
Website

Re: running agl and mormot in unix - simple ways of running

You could also use user-based systemd, then you don't need to start the mORMot program as root. In this setup, your systemd files are in $HOME/.config/systemd/user, and you'd start/stop the service as follows, as your own UID:

% systemctl --user start yourmormotservice
% systemctl --user stop yourmormotservice

Also, why run agl under systemd at all, since systemd has agl's functionality?

Offline

#3 Yesterday 12:04:18

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 500

Re: running agl and mormot in unix - simple ways of running

PierceNg wrote:

You could also use user-based systemd, then you don't need to start the mORMot program as root. In this setup, your systemd files are in $HOME/.config/systemd/user, and you'd start/stop the service as follows, as your own UID:

% systemctl --user start yourmormotservice
% systemctl --user stop yourmormotservice

Also, why run agl under systemd at all, since systemd has agl's functionality?


You have right and thank you, I did not notice the --user option, that make thinks less complicate, I will test it.
I have an "agl" as a derived class from TSynAngelize to do more functions I need. For sure, I can have the same results with scripts and systemd but I want to have as more unified as possible code for both linux and windows

Offline

Board footer

Powered by FluxBB