我有以下 systemd 单元文件/etc/systemd/system/emacs.service
:
[Unit]
Description=Emacs: the extensible, self-documenting text editor
Documentatin=man:emacs(1) info:Emacs
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook nil) (kill-emacs))"
Restart=always
Environment=DISPLAY=:%i
TimeoutStartSec=0
[Install]
WantedBy=default.target
Run Code Online (Sandbox Code Playgroud)
我希望它在启动时启动,所以我输入了 systemctl enable emacs
但是,每次我的服务重新启动时,都会systemctl status emacs
显示:
? emacs.service - Emacs: the extensible, self-documenting text editor
Loaded: loaded (/etc/systemd/system/emacs.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Run Code Online (Sandbox Code Playgroud)
但随后进入systemctl start emacs
并检查状态返回:
? emacs.service - Emacs: the extensible, self-documenting text editor
Loaded: loaded (/etc/systemd/system/emacs.service; disabled; vendor preset: enabled)
Active: active (running) since Fri 2016-11-11 23:03:59 UTC; 4s ago
Process: 3151 ExecStart=/usr/bin/emacs --daemon (code=exited, status=0/SUCCESS)
Main PID: 3154 (emacs)
Tasks: 2
Memory: 7.6M
CPU: 53ms
CGroup: /system.slice/emacs.service
??3154 /usr/bin/emacs --daemon
Run Code Online (Sandbox Code Playgroud)
我怎样才能让这个过程在启动时成功启动?
Sta*_*tec 23
我不知道为什么,但要让它发挥作用,我:
已删除 Environment=DISPLAY=:%i
添加了一个User=
变量
确保正确的文件在/etc/systemd/system/emacs.service
(之前它是一个硬链接)
并重新运行 systemctl enable emacs
这使它起作用。
编辑
这里真正的问题是我在第 3 行有一个错字:
Documentatin
我通过检查发现了这一点journalctl
。我建议任何对 systemd 脚本有问题的人都这样做,因为没有错误发送到 stderr。
归档时间: |
|
查看次数: |
85951 次 |
最近记录: |