Systemd,节外赋值。忽略

hor*_*eds 4 systemd activemq-artemis

systemd我看到Apache ActiveMQ Artemis出现以下许多错误。

Sep 25 04:41:17 server systemd[1]: /etc/systemd/system/artemis.service:1: Assignment outside of section. Ignoring.
Sep 25 04:41:17 server systemd[1]: /etc/systemd/system/artemis.service:2: Assignment outside of section. Ignoring.
Run Code Online (Sandbox Code Playgroud)

我从这里获取了一些有用的建议,但据我所知该文件没问题。

> file artemis.service
artemis.service: ASCII text
Run Code Online (Sandbox Code Playgroud)

所以我认为文件格式是正确的,并且我没有看到任何额外的字符:

> cat -A artemis.service
Description=Apache ActiveMQ Artemis$
After=network.target$
[Service]$
Type=simple$
User=activemq$
Group=activemq$
ExecStart=/var/lib/broker-HA/bin/artemis run$
#ExecStop=/var/lib/broker-HA/bin/artemis stop$
UMask=0007$
RestartSec=10$
Restart=always$
[Install]$
WantedBy=multi-user.target$
Run Code Online (Sandbox Code Playgroud)

可能是什么原因造成的?

小智 10

我也遇到了这个问题,并通过在 .service 文件中添加 [Unit] 来解决。

这 2 行意味着您的 .service 文件,第 1 行和第 2 行有错误:

/etc/systemd/system/artemis.service:1
/etc/systemd/system/artemis.service:2
Run Code Online (Sandbox Code Playgroud)

解决方案:

[Unit]
Description=Apache ActiveMQ Artemis$ 
After=network.target$ 
[Service]$ 
Type=simple$ 
User=activemq$ 
Group=activemq$ 
ExecStart=/var/lib/broker-HA/bin/artemis run$ 
#ExecStop=/var/lib/broker-HA/bin/artemis stop$ 
UMask=0007$ RestartSec=10$ Restart=always$ 
[Install]$ 
WantedBy=multi-user.target$
Run Code Online (Sandbox Code Playgroud)

你可以尝试一下:)