繁体   English   中英

我如何启动使用Jruby

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM