systemd:在service文件中给Exec传入多个参数

有些话、适合烂在心里 提交于 2019-12-03 21:07:13

原问题是这样的:

答案是这样的:

此外在使用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"'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!