From a310029890df6d558a8daa6d89c37ee144b482ef Mon Sep 17 00:00:00 2001 From: Morten Siebuhr Date: Thu, 22 Mar 2018 15:31:53 +0100 Subject: [PATCH] Add example launchctl-file for MacOS (#856) * Add example LaunchCtl-file for MacOS Signed-off-by: Morten Siebuhr * Rewrite program location in launctctl file This seem to be the way most plist files does it. Signed-off-by: Morten Siebuhr * Make launct-agent run as nobody/nobody Signed-off-by: Morten Siebuhr * Rename plist per general naming scheme Signed-off-by: Morten Siebuhr * Pass arguments-file when launched through launchctl Signed-off-by: Morten Siebuhr --- examples/launchctl/README.md | 26 +++++++++++++ .../io.prometheus.node_exporter.plist | 38 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 examples/launchctl/README.md create mode 100644 examples/launchctl/io.prometheus.node_exporter.plist diff --git a/examples/launchctl/README.md b/examples/launchctl/README.md new file mode 100644 index 00000000..39e440c7 --- /dev/null +++ b/examples/launchctl/README.md @@ -0,0 +1,26 @@ +# MacOS LaunchAgent + +If you're installing through a package manager, you probably don't need to deal +with this file. + +The `plist` file should be put in `~/Library/LaunchAgents/` (user-install) or +`/Library/LaunchAgents/` (global install), and the binary installed at +`/usr/local/bin/node_exporter`. + +Ex. install globally by + + sudo cp -n node_exporter /usr/local/bin/ + sudo cp -n examples/launchctl/io.prometheus.node_exporter.plist /Library/LaunchAgents/ + sudo launchctl bootstrap system/ /Library/LaunchAgents/io.prometheus.node_exporter.plist + + # Optionally configure by dropping CLI arguments in a file + echo -- '--web.listen-address=:9101' | sudo tee /usr/local/etc/node_exporter.args + + # Check it's running + sudo launchctl list | grep node_exporter + + # See full process state + sudo launchctl print system/io.prometheus.node_exporter + + # View logs + sudo tail /tmp/node_exporter.log diff --git a/examples/launchctl/io.prometheus.node_exporter.plist b/examples/launchctl/io.prometheus.node_exporter.plist new file mode 100644 index 00000000..f32ffb88 --- /dev/null +++ b/examples/launchctl/io.prometheus.node_exporter.plist @@ -0,0 +1,38 @@ + + + + + Label + io.prometheus.node_exporter + ProgramArguments + + sh + -c + /usr/local/bin/node_exporter $(< /usr/local/etc/node_exporter.args) + + UserName + nobody + GroupName + nobody + RunAtLoad + + KeepAlive + + WorkingDirectory + /usr/local + StandardErrorPath + /tmp/node_exporter.log + StandardOutPath + /tmp/node_exporter.log + HardResourceLimits + + NumberOfFiles + 4096 + + SoftResourceLimits + + NumberOfFiles + 4096 + + +