【问题标题】:Port Upstart Script to Systemd将 Upstart 脚本移植到 Systemd
【发布时间】:2016-01-13 14:07:45
【问题描述】:

我目前正在构建一个基于 Ubuntu 15.10 的 miniroot。因此我想使用systemd。 我的标准脚本 '/etc/init.d/script' 由 systemd 找到并执行。 但是,我也确实有一个位于 /etc/init/script.conf 的脚本的 conf 未执行。因此我编写了这个 systemd 脚本

[Unit]
Description=Job that starts the startmaster.sh in /usr/bin/local/
Requires=script.service
After=script.service

[Service]
Type=forking
ExecStart=/sbin/getty -l /usr/local/bin/startmaster.sh -n 38400 tty6

[Install]
WantedBy=multi-user.target

此脚本在启动时执行,但未显示预期行为

startmaster.py 的内容 #!/bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

#vt=$1
vt=6


sleep 1
chvt $vt
sleep 1
chvt $vt
sleep 1
chvt $vt

screen -U master.py

exec getty 38400 tty$vt

dmesg 显示以下段错误

[ 2106.122116] master.py[3960]: segfault at 0 ip 00007f731ccfa892 sp 00007ffdb76d5620 error 4 in libc-2.21.so[7f731cc76000+1c0000]

关于如何解决此问题的任何建议

【问题讨论】:

    标签: segmentation-fault upstart systemd ubuntu-15.10


    【解决方案1】:

    我不确定您为什么需要 getty 和 vt 复杂性。 master.py 是否需要人工输入?为什么不直接从 systemd 单元运行master.py?如果您需要监控它,您可以通过运行journalctl -u master.service 查看来自master.py 的输出来实现。

    这要简单得多。请尝试一下,看看它是否适合您的需求

    [Unit]
    Description=Master service that does xyz
    
    [Service]
    Type=simple
    ExecStart=/usr/local/master.py
    
    [Install]
    WantedBy=multi-user.target
    

    【讨论】:

    • 如果某些信息没有给出用户需要完成它们,因此我需要人工交互。
    • 我按照你的方法试了一下,出现以下错误.... master.py[3847]: TERM environment variable needs set....Failed with result'exit'code'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-23
    • 1970-01-01
    • 2021-01-11
    相关资源
    最近更新 更多