systemctl 服務未啟動

systemctl 服務未啟動

我為我的 RaspBerryPi 專案提供了一項服務。當我開始時什麼也沒有發生。systemctl status sb.service返回這個:

Failed to start RPI-sound board.
Unit entered failed state.
Failed with result 'exit-code'.

某人服務:

[Unit]
Description=RPI-sound board
After=network.target

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/home/pi/Desktop/RPSB/RpiSoundBoard.sh
User=pi

[Install]
WantedBy=multi-user.target

它應該運行的文件是在這裡舉辦。如果我自己運行它們,它們就運行得很好。如何從我的服務中獲得更多輸出/或解決此問題?

答案1

發現問題在/var/log/syslog.

    Traceback (most recent call last):
    File "/home/pi/Desktop/RPSB/soundPlayer.py", line 1, in <module>
    from pynput.keyboard import Key, Listener
    File "/home/pi/.local/lib/python3.5/site-packages/pynput/__init__.py", line 40, in <module>
    from . import keyboard
    File "/home/pi/.local/lib/python3.5/site-packages/pynput/keyboard/__init__.py", line 49, in <module>
    from ._xorg import KeyCode, Key, Controller, Listener
    File "/home/pi/.local/lib/python3.5/site-packages/pynput/keyboard/_xorg.py", line 39, in <module>
    from pynput._util.xorg import (
    File "/home/pi/.local/lib/python3.5/site-packages/pynput/_util/xorg.py", line 40, in <module>
    _check()
    File "/home/pi/.local/lib/python3.5/site-packages/pynput/_util/xorg.py", line 38, in _check
    display = Xlib.display.Display()
    File "/home/pi/.local/lib/python3.5/site-packages/Xlib/display.py", line 89, in __init__
    self.display = _BaseDisplay(display)
    File "/home/pi/.local/lib/python3.5/site-packages/Xlib/display.py", line 71, in __init__
    protocol_display.Display.__init__(self, *args, **keys)
    File "/home/pi/.local/lib/python3.5/site-packages/Xlib/protocol/display.py", line 84, in __init__
    name, protocol, host, displayno, screenno = connect.get_display(display)
    File "/home/pi/.local/lib/python3.5/site-packages/Xlib/support/connect.py", line 73, in get_display
    return mod.get_display(display)
    File "/home/pi/.local/lib/python3.5/site-packages/Xlib/support/unix_connect.py", line 76, in get_display
    error.DisplayNameError(display)
    Xlib.error.DisplayNameError: Bad display name ""

相關內容