Macos osx startupitems外壳脚本不启动应用程序
我正试图在OSX 10.10.4上使用shell脚本启动一个与之相关的项目的匿名服务器应用程序 shell脚本已设置为可执行 启动时,启动Wakanda\Server.app/Contents/MacOS/Wakanda\Server不会发生任何事情 请帮我完成这项工作 shell脚本位于:Macos osx startupitems外壳脚本不启动应用程序,macos,startup,wakanda,Macos,Startup,Wakanda,我正试图在OSX 10.10.4上使用shell脚本启动一个与之相关的项目的匿名服务器应用程序 shell脚本已设置为可执行 启动时,启动Wakanda\Server.app/Contents/MacOS/Wakanda\Server不会发生任何事情 请帮我完成这项工作 shell脚本位于: Macintosh HD:Library:StartupItems:DispatchStartup:DispatchStartup.sh 此shell脚本的内容是: #!/bin/sh . /etc/rc
Macintosh HD:Library:StartupItems:DispatchStartup:DispatchStartup.sh
此shell脚本的内容是:
#!/bin/sh
. /etc/rc.common
# The start subroutine
StartService() {
# Insert your start command below. For example:
/Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server --solution=/Applications/Dispatch/Dispatch\ Solution/Dispatch.waSolution
# End example.
}
# The stop subroutine
StopService() {
# Insert your stop command(s) below. For example:
killall -TERM /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server
sleep 15
killall -9 /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server
# End example.
}
# The restart subroutine
RestartService() {
# Insert your start command below. For example:
killall -HUP /Applications/Wakanda\ Server.app/Contents/MacOS/Wakanda\ Server
# End example.
}
RunService "$1"
//-------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>Description</key>
<string>Wakanda Server</string>
<key>OrderPreference</key>
<string>Late</string>
<key>Provides</key>
<array>
<string>Web service to database and objects</string>
</array>
<key>Uses</key>
<array>
<string>Network</string>
</array>
</dict>
</plist>
//shell脚本旁边是StartParameters.plist
//--------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>Description</key>
<string>Wakanda Server</string>
<key>OrderPreference</key>
<string>Late</string>
<key>Provides</key>
<array>
<string>Web service to database and objects</string>
</array>
<key>Uses</key>
<array>
<string>Network</string>
</array>
</dict>
</plist>
描述
Wakanda服务器
订单偏好
晚的
提供
数据库和对象的Web服务
使用
网络
自OS X v10.4以来,启动项一直被弃用,取而代之的是,它们似乎最终在v10.10中被完全禁用。更好的选择是。。。而是创建一个启动守护进程。它将是/Library/LaunchDaemons/中的属性列表(.plist)文件,其中包含关于启动内容和启动时间的说明
这将比平常更复杂一点,因为launchd系统喜欢跟踪它启动的作业,这要求它们不要掉到后台,而且我看不到任何阻止Wakanda服务器自身后台化的方法。您可以通过向.plist添加指令来解决此问题,使其不保持活动状态,并“放弃”其进程组(即,不杀死它产生的任何剩余后台进程)。也可能有一个问题,就是没有好的方法告诉它等待网络启动。但如果它试图监听特定的IP地址或接口,这通常是一个问题;如果它只监听0.0.0.0(即计算机上的所有IP),这不是问题,因为它只会在接口出现时拾取接口
我认为.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>Label</key>
<string>local.wakanda-server</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Wakanda Server.app/Contents/MacOS/Wakanda Server</string>
<string>--solution=/Applications/Dispatch/Dispatch Solution/Dispatch.waSolution</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>AbandonProcessGroup</key>
<false/>
</dict>
</plist>
残废
标签
local.wakanda-server
程序参数
/Applications/Wakanda Server.app/Contents/MacOS/Wakanda Server
--解决方案=/Applications/Dispatch/Dispatch solution/Dispatch.waSolution
运行负荷
持久连接
放弃进程组
将其放入/Library/LaunchDaemons/local.wakanda-server.plist,将所有权设置为root:wheel,权限设置为644,然后重新启动或使用
sudo launchctl load/Library/LaunchDaemons/local.wakanda-server.plist手动加载它。戈登,你的答案很完美!很少有人给我一个像帖子一样有效的答案。谢谢!!!:-)