【问题标题】:Missing '='. in Debian service [closed]缺少“=”。在 Debian 服务中[关闭]
【发布时间】:2020-06-01 09:46:20
【问题描述】:

我已经在 /etc/systemd/system/webapp.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$

【问题讨论】:

  • 您可以尝试几件事: 1. 删除等号周围的所有空格。 2.运行sudo systemctl daemon-reload
  • 你可以试试“sudo systemctl daemon-reload”吗?然后重启服务。
  • cat 输出看,您的服务的单元文件看起来不错。运行sudo systemctl reload-or-restart webapp.service,如果仍然遇到同样的错误,请分享。
  • 服务文件是 UTF-8 编码的吗?

标签: linux debian system daemon


【解决方案1】:

你的配置内容好像没什么问题,所以我把它复制到我的debian服务器上尝试运行,真的没问题。

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

参考:https://wiki.debian.org/systemd/Services

  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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-08
    • 1970-01-01
    相关资源
    最近更新 更多