jruby を使用して x プラットフォーム アプリを開発しています。このアプリを Mac で実行するときは、launchd を使用して定期的に起動したいと考えています。
私の問題は、launchd が必要な gem がインストールされていないシステム ruby (/usr/bin/ruby) を使用しているように見えることです。
launchd do がシステム ルビーの代わりに jruby を使用するように強制する何らかのリンクを作成する方法はありますか?
ありがとう、HS
ここで答えを見つけました:launchdを介したWatirスクリプト
これは、rvm を設定し、指定された ruby バージョンで ruby スクリプトを実行する私の bash スクリプトです。
############
#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
##########
bash スクリプトは、次の plist を使用して launchd を介して起動されます。
<?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>