[英]How do I get launchd to use jruby
I'm using jruby to develop a x-platform app. 我正在使用jruby开发一个x平台应用程序。 When running this app on a Mac I would like to use launchd to launch it periodically.
在Mac上运行此应用程序时,我想使用launchd定期启动它。
My trouble is that launchd seems to use the system ruby (/usr/bin/ruby) where none of my required gems are installed. 我的麻烦是,启动似乎会使用系统ruby(/ usr / bin / ruby),其中没有安装我所需的gem。
Is there a way I can create some sort of link to force the launchd do to use the jruby instead of the system ruby? 有没有一种方法可以创建某种链接来强制启动的do使用jruby而不是系统ruby?
Thanks, HS 谢谢,HS
I found the answer here: Watir scripts via launchd 我在这里找到了答案: 通过启动Watir脚本
This is my bash script which sets rvm then runs the ruby script with the specified ruby version: 这是我的bash脚本,该脚本设置rvm然后以指定的ruby版本运行ruby脚本:
############
#first arg is task_kind. Pass it on to the ruby script.
task_kind=$1
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
source "/usr/local/rvm/scripts/rvm"
else
printf "ERROR: An RVM installation was not found.\n"
fi
echo "Launching TaskManagerRunner for $task_kind."
#first arg in the next line is the specific ruby needed for the script.
#second arg is the script.
#third arg is the script param.
/Users/haroldshields/.rvm/rubies/jruby-1.7.4/bin/ruby /Users/haroldshields/Documents/Ivey/Projects/WMS/Code/Task_Engine/TaskManager.rb $task_kind
##########
The bash script is then launched via launchd with the following plist: 然后使用以下plist通过启动来启动bash脚本:
<?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>
<false/>
<key>Label</key>
<string>local.ivey.wms.TaskManager.SftpTasks</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/Users/haroldshields/Documents/Ivey/Projects/WMS/Code/Task_Engine/TaskManagerRunner.sh</string>
<string>SftpTasks</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>15</integer>
</dict>
</plist>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.