Skip to content

fix: allow biliroaming server to exit cleanly on systemd stop - #140

Open
sanba0519 wants to merge 1 commit into
pchpub:mainfrom
sanba0519:main
Open

fix: allow biliroaming server to exit cleanly on systemd stop#140
sanba0519 wants to merge 1 commit into
pchpub:mainfrom
sanba0519:main

Conversation

@sanba0519

Copy link
Copy Markdown

问题

在使用 systemd 运行 biliroaming_rust_server 时,执行:

systemctl stop biliroaming

服务无法正常退出,systemd 会等待停止超时时间结束后发送 SIGKILL 强制杀死进程。

但是直接在终端运行时,Ctrl+C 可以正常退出。

原因

目前程序只监听了 Ctrl+C 信号:

ctrlc::set_handler(...)

改动

在程序侧用 tokio::signal 同时监听:

  • SIGINT:保留原来的 Ctrl+C 行为
  • SIGTERM:与 Ctrl+C 走同一套退出逻辑(打日志后 process::exit(0))

@sanba0519

Copy link
Copy Markdown
Author

在Debian 13(aarch64)设备测试通过

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant