如何让这个systemd脚本在ArchLinux上运行?

时间:2015-03-01 18:47:54

标签: linux systemd

我有一个连接到运行arch linux的机器的火线设备。

我让FFADO工作了,在我执行ffado-dbus-server后,我可以开始使用带有Jack和Pulseaudio的火线设备(这个卷积与我的问题完全无关)

每次启动时我基本上都要运行3个不同的步骤以使我的声音正常工作。我试图在启动时自动发生所有这些魔法。

我读到了/etc/rc.local,但似乎我的arch linux安装中没有这样的文件。我读到了关于arch linux的启动过程,似乎arch不使用rc.local而是使用systemd

我浏览了arch wiki page on systemd并尝试在ffado-dbus.service

中创建一个简单的/usr/lib/systemd/system单元文件

我开始尝试使用单位类型dbus,然后尝试oneshot,最后simple

无论我做什么,结果都非常一致。服务失败。

我还尝试将服务放在usr/lib/systemd/user中,并尝试将其作为systemctl --user start运行,但也会产生同样的失败。

我所拥有的单位文件的最简单的例子是:

[Unit]
Description=FFADO DBus startup

[Service]
Type=simple
ExecStart=/usr/sbin/ffado-dbus-server

产生以下状态:

[pigdog@livingroom system]$ sudo systemctl status ffado-dbus -l
● ffado-dbus.service - FFADO DBus Service
   Loaded: loaded (/usr/lib/systemd/system/ffado-dbus.service; static; vendor preset: disabled)
   Active: failed (Result: core-dump) since Sun 2015-03-01 04:31:59 MST; 5s ago
  Process: 3934 ExecStart=/usr/bin/ffado-dbus-server (code=dumped, signal=ABRT)
 Main PID: 3934 (code=dumped, signal=ABRT)

Mar 01 04:31:59 livingroom ffado-dbus-server[3934]: FFADO Control DBUS service
Mar 01 04:31:59 livingroom ffado-dbus-server[3934]: Part of the FFADO project -- www.ffado.org
Mar 01 04:31:59 livingroom ffado-dbus-server[3934]: Version: 2.2.1-Unversioned directory
Mar 01 04:31:59 livingroom ffado-dbus-server[3934]: (C) 2008, Pieter Palmers
Mar 01 04:31:59 livingroom ffado-dbus-server[3934]: This program comes with ABSOLUTELY NO WARRANTY.
Mar 01 04:31:59 livingroom ffado-dbus-server[3934]: -----------------------------------------------
Mar 01 04:31:59 livingroom systemd[1]: ffado-dbus.service: main process exited, code=dumped, status=6/ABRT
Mar 01 04:31:59 livingroom systemd[1]: Unit ffado-dbus.service entered failed state.
Mar 01 04:31:59 livingroom systemd[1]: ffado-dbus.service failed.
Mar 01 04:32:00 livingroom systemd-coredump[3944]: Process 3934 (ffado-dbus-serv) of user 0 dumped core.

ffado-dbus-server

的主要过程中会发生一些神秘的代码6 / ABRT

我认为这是因为运行systemd的“环境”不包含ffado需要运行的进程或内容。我不明白的是我如何确定缺少的内容,然后如何将其提供给systemd environemnt。

或者,我希望让systemd环境与我刚刚执行systemctl调用的“pigdog”用户环境相匹配。我认为这就是我将ffado-dbus.service文件移动到/usr/lib/systemd/user然后调用类似systemctl --user的系统,但这会产生相同的错误。

我还尝试将User=pigdog指令添加到单元文件的[Service]部分,但没有成功。

我可以在没有问题的情况下以pigdog身份登录时从bash运行/usr/bin/ffado-dbus-server。当脚本成功时,我得到以下输出:

[pigdog@livingroom system]$ /usr/bin/ffado-dbus-server
-----------------------------------------------
FFADO Control DBUS service
Part of the FFADO project -- www.ffado.org
Version: 2.2.1-Unversioned directory
(C) 2008, Pieter Palmers
This program comes with ABSOLUTELY NO WARRANTY.
-----------------------------------------------

1425209640984446:  (ffado-dbus-server.cpp)[ 270] main:  Discovering devices...
00973362057: Debug (devicemanager.cpp)[ 354] discover: Starting discovery...
00973405357: Debug (devicemanager.cpp)[ 616] discover: driver found for device 0
00973405880: Debug (devicemanager.cpp)[ 653] discover: discovery of node 0 on port 0 done...
00973405944: Debug (devicemanager.cpp)[ 661] discover: Discovery finished...
00973405980: Debug (devicemanager.cpp)[1258] showDeviceInfo: ===== Device Manager =====
00973406020: Debug (Element.cpp)[ 121] show: Element DeviceManager
00973406047: Debug (devicemanager.cpp)[1266] showDeviceInfo: --- IEEE1394 Service  0 ---
00973406085: Debug (devicemanager.cpp)[1276] showDeviceInfo: --- Device  0 ---
00973406113: Debug (devicemanager.cpp)[1279] showDeviceInfo: Clock sync sources:
00973406165: Debug (devicemanager.cpp)[1288] showDeviceInfo:  Type: Internal          , Id:  0, Valid: 1, Active: 1, Locked 1, Slipping: 0, Description: Internal sync
00973406199: Debug (devicemanager.cpp)[1288] showDeviceInfo:  Type: ADAT              , Id:  1, Valid: 1, Active: 1, Locked 1, Slipping: 0, Description: ADAT optical
00973406237: Debug (devicemanager.cpp)[1288] showDeviceInfo:  Type: SPDIF             , Id:  2, Valid: 1, Active: 1, Locked 1, Slipping: 0, Description: SPDIF/Toslink
00973406266: Debug (devicemanager.cpp)[1288] showDeviceInfo:  Type: Erratic type      , Id:  3, Valid: 0, Active: 0, Locked 0, Slipping: 0, Description: SMPTE
00973406303: Debug (devicemanager.cpp)[1288] showDeviceInfo:  Type: WordClock         , Id:  4, Valid: 1, Active: 1, Locked 1, Slipping: 0, Description: Wordclock
00973409421:  (ffado-dbus-server.cpp)[ 329] main: DBUS service running
00973409433:  (ffado-dbus-server.cpp)[ 330] main: press ctrl-c to stop it & exit
00973409436: Debug (ffado-dbus-server.cpp)[ 333] main: dispatching...

1 个答案:

答案 0 :(得分:0)

当您从shell提示符运行启动脚本时,它可以工作,但启动脚本在从systemd启动时失败 - 显然在您的情况下 - 百分之九十九的问题是环境。

我会将其作为业务的第一顺序进行调查 - ffado软件包是否设置了其启动脚本所需的一些默认shell环境变量。

如果是这样,那么在执行启动脚本之前,在systemd单元文件中设置相同的环境变量就变得很简单。