AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1003878

Ch3_ong's questions

Martin Hope
Ch3_ong
Asked: 2019-05-15 02:33:57 +0800 CST

systemctl 无法启动服务(代码=退出状态=0/成功)

  • 6

我在我的CentOS 7服务器上安装了Shadowsocks-r,我想用systemd来管理它。所以我在 /etc/systemd/system 中创建了一个名为 shadowsocks-r.service 的文件。

shadowsocks-r.service:

[Unit]
Description=Shadowsocks-R Server
After=network.target

[Service]
ExecStart=/usr/local/shadowsocks/server.py -c /etc/shadowsocks-r/config.json -d start
ExecStop=/etc/init.d/shadowsocks-r stop

[Install]
WantedBy=multi-user.target

但是服务无法正常启动。检查服务状态时,我得到以下信息:

shadowsocks-r.service - Shadowsocks-R Server
Loaded: loaded (/etc/systemd/system/shadowsocks-r.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Tue 2019-05-14 10:29:46 UTC; 8s ago
Process: 19267 ExecStop=/etc/init.d/shadowsocks-r stop (code=exited, status=0/SUCCESS)
Process: 19234 ExecStart=/etc/init.d/shadowsocks-r start (code=exited, status=0/SUCCESS)
Main PID: 19234 (code=exited, status=0/SUCCESS)

May 14 10:29:46 vultr.guest systemd[1]: Started Shadowsocks-R Server.
May 14 10:29:46 vultr.guest shadowsocks-r[19234]: 2019-05-14 10:29:46 INFO     util.py:94 loading libcrypto from libcrypto.so.10
May 14 10:29:46 vultr.guest shadowsocks-r[19234]: 2019-05-14 10:29:46 INFO     shell.py:74 ShadowsocksR 2.8.2
May 14 10:29:46 vultr.guest shadowsocks-r[19234]: IPv6 support
May 14 10:29:46 vultr.guest shadowsocks-r[19234]: Starting ShadowsocksR success
May 14 10:29:46 vultr.guest shadowsocks-r[19267]: 2019-05-14 10:29:46 INFO     shell.py:74 ShadowsocksR 2.8.2
May 14 10:29:46 vultr.guest shadowsocks-r[19267]: IPv6 support
May 14 10:29:46 vultr.guest shadowsocks-r[19267]: stopped
May 14 10:29:46 vultr.guest shadowsocks-r[19267]: Stopping ShadowsocksR success

消息 shadowsocks-r 来自启动和停止功能。从消息来看,启动和停止功能似乎都已执行。为什么会发生这种情况,我应该怎么做才能纠正它?谢谢!


更新:

跑步后systemctl start shadowsocks-r.service我尝试跑步journalctl -xe,这就是我得到的:

May 14 11:09:01 vultr.guest systemd[1]: Started Shadowsocks-R Server.
-- Subject: Unit shadowsocks-r.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit shadowsocks-r.service has finished starting up.
--
-- The start-up result is done.
May 14 11:09:01 vultr.guest polkitd[1547]: Unregistered Authentication Agent for unix-process:19521:1303198 (system bus name :1.57, object path
May 14 11:09:01 vultr.guest shadowsocks-r[19527]: 2019-05-14 11:09:01 INFO     util.py:94 loading libcrypto from libcrypto.so.10
May 14 11:09:01 vultr.guest shadowsocks-r[19527]: 2019-05-14 11:09:01 INFO     shell.py:74 ShadowsocksR 2.8.2
May 14 11:09:01 vultr.guest shadowsocks-r[19527]: IPv6 support
May 14 11:09:01 vultr.guest shadowsocks-r[19527]: Starting ShadowsocksR success
May 14 11:09:01 vultr.guest shadowsocks-r[19560]: 2019-05-14 11:09:01 INFO     shell.py:74 ShadowsocksR 2.8.2
May 14 11:09:02 vultr.guest shadowsocks-r[19560]: IPv6 support
May 14 11:09:02 vultr.guest shadowsocks-r[19560]: stopped
May 14 11:09:02 vultr.guest shadowsocks-r[19560]: Stopping ShadowsocksR success

- - - 更新 - - -

现在我又尝试了几次,确认 systemctl 命令实际上停止了进程,即使我使用命令“start”也是如此。这是我尝试过的:

  1. 首先我开始这个过程/etc/init.d/shadowsocks-r start

终端返回:

IPv6 support
2019-05-16 08:39:30 INFO     util.py:94 loading libcrypto from libcrypto.so.10
2019-05-16 08:39:30 INFO     shell.py:74 ShadowsocksR 2.8.2
started
Starting ShadowsocksR success
  1. 然后我跑systemctl start shadowsocks-r.service
  2. 然后我运行/etc/init.d/shadowsocks-r status,结果是:ShadowsocksR is stopped

所以即使当我使用其他方法启动 shadowsocks-r 进程时,即使我尝试启动它,systemctl 也会杀死它。

  1. 运行systemctl status shadowsocks-r.service,这是我得到的:
    shadowsocks-r.service - Shadowsocks-R Server
    Loaded: loaded (/etc/systemd/system/shadowsocks-r.service; enabled; vendor preset: disabled)
    Active: failed (Result: exit-code) since Thu 2019-05-16 08:45:10 UTC; 12min ago
    Process: 713 ExecStop=/usr/local/shadowsocks/server.py -c /etc/shadowsocks-r/config.json -d stop (code=exited, status=0/SUCCESS)
    Process: 686 ExecStart=/usr/local/shadowsocks/server.py -c /etc/shadowsocks-r/config.json -d start (code=exited, status=1/FAILURE)
    Main PID: 686 (code=exited, status=1/FAILURE)

    May 16 08:45:10 vultr.guest server.py[686]: 2019-05-16 08:45:10 INFO     shell.py:74 ShadowsocksR 2.8.2
    May 16 08:45:10 vultr.guest server.py[686]: 2019-05-16 08:45:10 ERROR    daemon.py:75 already started at pid 670
    May 16 08:45:10 vultr.guest server.py[686]: IPv6 support
    May 16 08:45:10 vultr.guest server.py[686]: IPv6 support
    May 16 08:45:10 vultr.guest systemd[1]: shadowsocks-r.service: main process exited, code=exited, status=1/FAILURE
    May 16 08:45:10 vultr.guest server.py[713]: 2019-05-16 08:45:10 INFO     shell.py:74 ShadowsocksR 2.8.2
    May 16 08:45:10 vultr.guest server.py[713]: IPv6 support
    May 16 08:45:10 vultr.guest server.py[713]: stopped
    May 16 08:45:10 vultr.guest systemd[1]: Unit shadowsocks-r.service entered failed state.
    May 16 08:45:10 vultr.guest systemd[1]: shadowsocks-r.service failed.

- - - -更新 - - - -

根据@Daniel B 的建议,我删除了服务文件中的 ExecStop 行:

[Unit]
Description=Shadowsocks-R Server
After=network.target

[Service]
ExecStart=/usr/local/shadowsocks/server.py -c /etc/shadowsocks-r/config.json -d start

[Install]
WantedBy=multi-user.target

我首先停止 server.py 进程,/etc/init.d/shadowsocks-r stop然后它返回ShadowsocksR is stopped

然后我跑

systemctl daemon-reload
systemctl start shadowsocks-r.service
systemctl status shadowsocks-r.service

我仍然收到错误消息,似乎 systemctl 命令无法启动进程(在它可以启动之前停止进程)

shadowsocks-r.service - Shadowsocks-R Server
   Loaded: loaded (/etc/systemd/system/shadowsocks-r.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Thu 2019-05-16 09:40:43 UTC; 29s ago
  Process: 2964 ExecStart=/usr/local/shadowsocks/server.py -c /etc/shadowsocks-r/config.json -d start (code=exited, status=0/SUCCESS)
 Main PID: 2964 (code=exited, status=0/SUCCESS)

May 16 09:40:43 vultr.guest systemd[1]: Started Shadowsocks-R Server.
May 16 09:40:43 vultr.guest server.py[2964]: 2019-05-16 09:40:43 INFO     util.py:94 loading libcrypto from libcrypto.so.10
May 16 09:40:43 vultr.guest server.py[2964]: 2019-05-16 09:40:43 INFO     shell.py:74 ShadowsocksR 2.8.2
May 16 09:40:43 vultr.guest server.py[2964]: IPv6 support
linux centos-7
  • 2 个回答
  • 8604 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve