sealdice / sealdice-core

海豹骰核心程序,船新的trpg骰点机器人。轻量易用,功能强大,支持所有主流IM平台,并能在win/linux/mac/android下使用。
https://sealdice.com
MIT License
148 stars 37 forks source link

[改进] macOS 运行为服务时配置不正确 #1028

Open oissevalt opened 1 month ago

oissevalt commented 1 month ago

目前在 macOS 上将海豹运行为服务,会创建 /Library/LaunchDaemons/sealdice.plist 并写入:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>sealdice</string>
    <key>ProgramArguments</key>
    <array>
        <string>/海豹目录/sealdice-core</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>SessionCreate</key>
    <false/>
    <key>StandardErrorPath</key>
    <string>/var/log/sealdice.err.log</string>
    <key>StandardOutPath</key>
    <string>/var/log/sealdice.out.log</string>
    <key>WorkingDirectory</key>
    <string>/海豹目录/sealdice146</string>
</dict>
</plist>

此行为有如下不妥:

  1. /Library/LaunchDaemons 中创建的服务是放在 system 域下的,用户操作需要 sudo 权限;
  2. 原因不明,但用户无法通过 launchctl startlaunchctl stop 来开关服务,而要用 launchctl bootstraplaunchctl bootout
  3. 在菜单栏退出海豹后,系统会立刻重启服务,除非用 sudo launchctl bootout system/sealdice 停止。