【发布时间】:2021-02-03 16:26:27
【问题描述】:
我正在尝试制作一个 MacOS 代理以在启动时启动单声道服务。问题是加载的守护进程退出时没有任何错误(没有输出到 console.log、err.log - 请参见下面的 agent.plist),但 mono-service2 不会创建 my.lock 文件并启动服务。 如果我手动点击启动脚本,它会完美运行。有什么建议吗?
环境:
- MacOS:Catalina 10.15.7
- 单框架:6.12.0.90
代理负载:
launchctl load /Library/LaunchDaemons/agent.plist
agent.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>agent</string>
<key>UserName</key>
<string>me</string>
<key>StandardErrorPath</key>
<string>/Users/me/Desktop/err.log</string>
<key>StandardOutPath</key>
<string>/Users/me/Desktop/console.log</string>
<key>KeepAlive</key>
<false/>
<key>LaunchOnlyOnce</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>Program</key>
<string>/bin/bash</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>/Applications/my.app/Contents/MacOS/Start</string>
</array>
</dict>
</plist>
启动脚本:
#!/bin/bash
LOCK_FILE="my.lock"
MONO_DIR="/Library/Frameworks/Mono.framework"
cd `dirname "$0"`
rm -f $LOCK_FILE
$MONO_DIR/Commands/mono-service2 -l:$LOCK_FILE Service.exe
【问题讨论】: