You are not logged in.
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
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 yourmormotserviceAlso, why run agl under systemd at all, since systemd has agl's functionality?
Offline
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 yourmormotserviceAlso, 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