Netbeans和Rails:有没有办法使Netbeans中的Run选项也开始think_sphinx? [英] Netbeans and Rails: Is there a way to make the Run option in netbeans also start thinking_sphinx?

查看:84
本文介绍了Netbeans和Rails:有没有办法使Netbeans中的Run选项也开始think_sphinx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想让狮身人面像一直在我的开发机器上运行.当我通过netbeans运行我的应用程序时,我想一种自动执行rake thinking_sphinx:start的方法.有没有办法做到这一点

I don't want to keep sphinx running all the time on my dev machine. I'd like a way to automatically execute rake thinking_sphinx:start when I run my app via netbeans. Is there a way to do this

[也-我正在使用Windows]

[also - I am using Windows]

思维狮身人面像需要作为单独的进程运行.

Thinking sphinx needs to run as a separate process.

推荐答案

您将需要一个名为PsExec的第三方程序来执行此操作.否则,您将无法在Windows上使用Ruby启动后台进程.

You will need a third-party program called PsExec to do this. Otherwise you won't be able to start a background process using Ruby on Windows.

首先在此处下载PsExec.打开(至少)psexec.exe的包装并手动运行一次-您必须同意许可:-/.

First of all download PsExec here. Unpack (at least) psexec.exe and run it once manually - you have to agree to the license :-/.

之后,将以下行添加到Rails应用的script/server中:

After that add the following line to script/server of your Rails app:

system 'PATH_TO_PSEXEC/psexec -d rake.bat'

现在,使用与服务器并行运行的命令创建rake.bat.将具有以下内容的文件放入Rails应用程序的根目录中.

Now you create the rake.bat with the commands to run in parallel to your server. Put the file with the following contents into your Rails app's root directory.

rake thinking_sphinx:start

这行应该可以解决问题,但可能会失败,例如当NetBeans的JRuby版本不同于主机上安装的Ruby时.或者,如果根本没有安装Ruby.在这种情况下,您应该使用JRuby的完整路径调用rake:

This line should do the trick, but it may fail e.g. when NetBeans' JRuby version differs from Ruby installed on your host. Or if Ruby isn't installed at all. In that case you should call rake with the complete path of JRuby:

"PATH_TO_NETBEANS/ruby2/jruby-1.2.0/bin/jruby" "PATH_TO_NETBEANS/ruby2/jruby-1.2.0/bin/rake" thinking_sphinx:start

现在启动服务器时,会弹出一个Windows命令行,其中包含正在运行的rake任务.

When you start the server now, an additional Windows command-line pops up with the running rake task.

不用说,您不应该将代码添加到生产服务器上的script/server中.

Needless to say that you shouldn't add the code to script/server on your production server.

这篇关于Netbeans和Rails:有没有办法使Netbeans中的Run选项也开始think_sphinx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆