systemd:在service文件中給Exec傳入多個參數


原問題是這樣的:

答案是這樣的:

此外在使用prometheus監控mongodb時需要安裝prometheus-mongodb-exporter,過程中也發現這種用法:

看看service單元文件是怎么寫的:

cat /lib/systemd/system/prometheus-mongodb-exporter.service

內容如下:

[Unit]
Description=Prometheus exporter for MongoDB
Documentation=https://github.com/dcu/mongodb_exporter

[Service]
Restart=always
User=prometheus
EnvironmentFile=/etc/default/prometheus-mongodb-exporter
ExecStart=/usr/bin/prometheus-mongodb-exporter $ARGS

[Install]
WantedBy=multi-user.target

在看看這個 EnvironmentFile

cat /etc/default/prometheus-mongodb-exporter

內容如下:

# Set the command-line arguments to pass to the server.
ARGS='-mongodb.uri="mongodb://localhost:27017"'


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM