在Debian服务中缺少'='.[已关闭]。

问题描述 投票:2回答:1

我在etcsystemdsystemwebapp.service中创建了这个服务。

在...中

Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:    10

这就是内容。

[Unit]
Description=webapp daemon
After=network.target

[Service]
Type=notify
ExecStart=/usr/local/bin/start-webapp.sh
ExecStop=/usr/local/bin/stop-webapp.sh
ExecReload=/usr/local/bin/reload-webapp.sh
StandardOutput=null

[Install]
WantedBy=multi-user.target
Alias=webapp.service

我试着用这个服务来启动

sudo systemctl start webapp.service

但是当我这样做的时候

sudo systemctl status webapp.service 

我得到了这个错误。

● webapp.service - webapp daemon
   Loaded: loaded (/etc/systemd/system/webapp.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Jun 01 11:31:48 localhost systemd[1]: /etc/systemd/system/webapp.service:8: Missing '='.
Jun 01 11:31:52 localhost systemd[1]: /etc/systemd/system/webapp.service:8: Missing '='.
Jun 01 11:35:21 localhost systemd[1]: /etc/systemd/system/webapp.service:8: Missing '='.
Jun 01 11:35:31 localhost systemd[1]: /etc/systemd/system/webapp.service:8: Missing '='.

   admin@localhost:/etc/systemd/system$ cat -vetn webapp.service 
         1  [Unit]$
         2  Description=webapp daemon$
         3  [Service]$
         4  Type=simple$
         5  ExecStart=/usr/local/bin/start-webapp.sh$
         6  ExecStop=/usr/local/bin/stop-webapp.sh$
         7  ExecReload=/usr/local/bin/reload-webapp.sh$
         8  [Install]$
         9  WantedBy=multi-user.target$
linux debian system daemon
1个回答
0
投票

你的配置内容似乎没有什么问题,所以我把它复制到了我的debian服务器上,试着运行它,果然没问题。

但是很奇怪的是,在你的配置中的stdout cat -vetn webapp.service 和你原来的配置内容不一样,所以你可以把原来的配置删除再做一次吗?

参考。https:/wiki.debian.orgsystemdServices。

  1. 重做。

    mv webapp.service /tmp/webapp.service vi webapp.service # check characters

  2. 在创建或修改任何单元文件后,我们必须告诉systemd 我们希望它寻找新的东西。

    systemctl daemon-reload

  3. 然后,告诉systemd启用它,让它在每次启动时都能启动。

    systemctl enable myservice.service

  4. 最后,启动它

    systemctl start myservice.service

© www.soinside.com 2019 - 2024. All rights reserved.