Skip to content

Instantly share code, notes, and snippets.

@boneskull
Last active June 26, 2024 18:01
Show Gist options
  • Save boneskull/e6d57d6793804f3e5f171cd5518cb08b to your computer and use it in GitHub Desktop.
Save boneskull/e6d57d6793804f3e5f171cd5518cb08b to your computer and use it in GitHub Desktop.
Run glances webserver as a user service (agent) on macOS

com.boneskull.glances-web

This launch agent will automatically start a glances web server

Installation

  1. Install Homebrew.
  2. Install glances. Execute brew install glances.
  3. Copy the .plist file in this gist into ~/Library/LaunchAgents/.
  4. EDIT the .plist: change /Users/boneskull/ to /Users/<you>/
  5. Execute launchctl load ~/Library/LaunchAgents/com.boneskull.glances-web.plist. Do not run this command with superuser privileges.

Notes

  • You can also just install glances via pip3 if you have it.
  • This may be better installed as a global daemon instead of a user agent.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.boneskull.glances-web</string>
<key>ProcessType</key>
<string>Interactive</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/glances</string>
<string>-w</string>
</array>
<key>StandardErrorPath</key>
<string>/Users/boneskull/Library/Logs/com.boneskull.glances-web.err.log</string>
<key>StandardOutPath</key>
<string>/Users/boneskull/Library/Logs/com.boneskull.glances-web.log</string>
</dict>
</plist>
@iamronr
Copy link

iamronr commented Jun 26, 2024

ah no. I don’t know where it’d be. run which glances from terminal and it should tell you. use that

Comes back to this -> /Library/Frameworks/Python.framework/Versions/3.12/bin/glances

Going to test it in a few and see if it works...

I've been getting this in terminal:

Load failed: 5: Input/output error
Try running `launchctl bootstrap` as root for richer errors.

@iamronr
Copy link

iamronr commented Jun 26, 2024

I solved it. For local installs using pip3, routing to the glances script is necessary. Using which glances like you suggested showed the path. My error that I was getting was a result of glances-web already being loaded. I had to unload and reload to get it working again. I used an app called LaunchControl on macOS to aid.

Thanks a lot for the right up. I finally have glances going, and have added it to my server dashboard -- gethomepage.dev

@boneskull
Copy link
Author

@iamronr LaunchControl is great!

@iamronr
Copy link

iamronr commented Jun 26, 2024

I agree! 100%. I had no idea about it until I actually needed something like it. Now it's a must-have app for me and my self-hosted stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment