[英]How do I get launchd to use jruby
我正在使用jruby開發一個x平台應用程序。 在Mac上運行此應用程序時,我想使用launchd定期啟動它。
我的麻煩是,啟動似乎會使用系統ruby(/ usr / bin / ruby),其中沒有安裝我所需的gem。
有沒有一種方法可以創建某種鏈接來強制啟動的do使用jruby而不是系統ruby?
謝謝,HS
我在這里找到了答案: 通過啟動Watir腳本
這是我的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
##########
然后使用以下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.