glances
glances copied to clipboard
Unable to Autostart glances using the systemd instructions [SOLVED]
[SOLVED] See first comment below.
I followed the instructions from here to autostart glances using systemd. https://github.com/nicolargo/glances/wiki/Start-Glances-through-Systemd
=====================================
After systemctl enable and start, I run systemctl status glances.service, I get this:
====================================
My glances.service file looks like this:
===================================
My Operating System:
===================================
My Glances & psutil versions
================================== My Install method:
pip install --user 'glances[all]'
It was installed in $HOME/.local/bin. I added this to my path in my .zshrc script. I can run 'glances -w' just fine from the terminal and it responds to the REST API calls. I just can not get it to autostart with systemd. I am open to other autostart methods if systemd is not going to work for me.
Thanks!
This stackoverflow article solved this issue for me.
https://stackoverflow.com/questions/35641414/python-import-of-local-module-failing-when-run-as-systemd-systemctl-service
I needed to tell systemd which user to run as. I also put in WorkingDirectory but don't know if that was required or not.
Note added to https://github.com/nicolargo/glances/wiki/Start-Glances-through-Systemd
for Fedora with SELinux enabled, this needs a couple extra steps:
/etc/systemd/system/glances.service
[Unit]
Description=Glances
After=network.target
[Service]
User=user
ExecStart=/home/user/.local/bin/glances -w
Restart=always
RemainAfterExit=no
[Install]
WantedBy=multi-user.target
then
sudo systemctl enable glances.service
sudo systemctl start glances.service
then by virtue of journalctl | grep glances
, SELinux tells you to create a local policy:
ausearch -c '(glances)' --raw | audit2allow -M my-glances
semodule -X 300 -i my-glances.pp
finally refresh the security context:
/sbin/restorecon -v /home/user/.local/bin/glances
and the service is now working.