- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在 Docker 环境中试用 systemd 脚本。
考虑一下:
ExecStartPre 中提到的命令更新环境文件,而 ExecStart 实际上使用了 env 中提到的环境变量。文件。?(都在同一个 systemd 文件中)。
像这样:
[Unit]
Description=test service
Before=memcached.service
[Service]
Type=oneshot
EnvironmentFile=-/etc/sysconfig/testfile
ExecStartPre=/usr/local/bin/update_sysconfig_testfile.sh
ExecStart=/usr/bin/testmebinary $VOLUMES
[Install]
WantedBy=multi-user.target
这里,$VOLUMES 在测试文件中定义,并由update_sysconfig_testfile.sh 脚本。
systemd 是否会知道 ExecStartPre 所做的更改(或)它只是加载测试文件中的任何值?
如果有更好的方法,请分享。
最佳答案
作为替代方法,考虑使用类似 with_testfile_vars
的脚本执行以下操作:
#!/bin/sh
export foo=bar # export the same calculated values you would otherwise write to the file
export baz=qux
exec "$@" # then invoke your "real" program
...使用该包装器的服务文件:
[Unit]
Description=test service
Before=memcached.service
[Service]
Type=oneshot
ExecStart=/usr/local/with_testfile_vars /usr/bin/testmebinary $VOLUMES
[Install]
WantedBy=multi-user.target
根本不需要 EnvironmentFile
,没有关于它的解释方式的顺序依赖性,不用担心 systemd 的解析与 shell 的解析有何不同,等等。
关于linux - systemd 脚本 - 由 ExecStartPre 更新的环境文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42835750/
我想在 systemd 的 myapp.service 文件中使用多个命令 [Unit] Description=to serve myapp [Service] User=ubuntu Workin
我想为 systemd 服务启用核心转储生成,该服务提供 SEGV 状态并退出。 scd.service: main process exited, code=killed, status=11/SE
我有一个由 systemd 运行的程序,其服务文件如下所示: [Unit] Description=... [Service] Type=notify ExecStart=/usr/sbin/mypr
我有一个 systemd 单元,参数中有空格 ExecStart=command --argument="text text" systemd 似乎无法识别双引号或单引号,并将参数拆分为两个参数。知道
我正在使用一个 systemd 服务,它在“启动”时调用一个进程(例如 systemctl start test.service)。根据设计,进程永远处于循环状态,我们可以使用 ps 命令查看进程的存
我的解决方案(到目前为止)是从公共(public) session 中评论 pam_systemd.so 。一切都在 system.slice 中运行,没有对照组。我还不确定这会产生什么影响,但至少一
我四处查看并用 google 搜索,找不到节点导出器公开的 systemd 指标列表? 最佳答案 node_systemd 指标列表: node_systemd_unit_state - System
我正在尝试将文件写入磁盘作为 ExecStartPre 的一部分systemd 单元文件的命令。 这就是我正在使用的: [Unit] Description=My service [Service]
我的 journalctl到处都是gnome-session警告。我已将问题追溯到谷歌浏览器,警告相对无害。然而,它淹没了我的日志输出,坦率地说,如果我确实需要检查它,我将无法找到我需要的东西。 Ma
操作系统级别:CentOS Linux release 7.4.1708普罗米修斯等级:2.4.2prometheus.service: [Unit] Description=Prometheus [
我们有一个 systemd 服务,根据建议的配置 here 来管理 Puma 进程。 . 虽然看起来运行良好,但重新启动超时,因此看起来失败,即使它们是成功的。如何调试这一类问题? systemd 期
systemd 可以让 rsyslog 守护进程保持事件状态,即使它死了,这真是太棒了。 但是我正在制作一个新的 rsyslog 配置文件,并且需要在 Debug模式下启动此 rsyslog 守护进程
我想更改 systemd-logind 服务的环境参数。这不在 configuration.nix 中可用的登录选项中,所以我尝试了 systemd = { services.system
我试图了解我的新项目中不同 systemd 服务之间的依赖关系。我们正在使用 yocto 构建系统和 systemd/系统服务。 如果我表现出色, systemctl -l 它将按字母顺序列出所有服务
我正在尝试在 lindux debian 上安装和配置 systemD,但在安装 systemd-sysv 时出现错误,我知道这是让 systemD 管理服务所必需的。 当我运行时 apt-get i
我有两个服务 A 和 B。 A 在启动时在 etcd 中设置一个值,比如它从环境文件中获取的公共(public) IP 地址: ExecStartPost=/usr/bin/etcdctl set /
我们目前在一台主机上运行着许多不同的服务,我们正在广泛使用 systemd,包括用于消息传递的 systemd-notify 和用于服务管理的自己的前端。 我们希望开始在容器内运行这些服务,以简化依赖
我们目前在一台主机上运行着许多不同的服务,我们正在广泛使用 systemd,包括用于消息传递的 systemd-notify 和用于服务管理的自己的前端。 我们希望开始在容器内运行这些服务,以简化依赖
几个月前,我使用 systemd.journal 编写了一个小型 Python 服务。 Pip list 显示我在相应的 virtualenv 中安装了 python-systemd (231)。 当
我想启动一个不存在的计时器,它应该在当时启动一个不存在的服务。这应该通过 systemd 临时单元(如 systemd-run)来完成。 当我执行以下代码时,我收到一个异常(见下文)。有人可以告诉我,
我是一名优秀的程序员,十分优秀!