首页 \ 问答 \ Resque / Redis的套接字权限问题(Socket permission problems with Resque/Redis)

Resque / Redis的套接字权限问题(Socket permission problems with Resque/Redis)

我试图在Passenger / Apache的简单Sinatra应用程序中使用Resque,但Resque试图访问Redis时会收到权限错误。 这种相同的错误发生在各种方法上,包括Resque.info和Resque.enqueue,并且无论redis-server是否实际运行

如果我在irb或ruby脚本中编写相同的代码,它运行良好。

我尝试切换哪些用户正在运行apache / passenger和redis,包括root。

App 31099 stdout: 
App 31082 stderr: 2015-10-01 12:23:52 - Errno::EACCES - Permission denied - connect(2):
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:122:in `connect_nonblock'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:122:in `connect_addrinfo'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:162:in `block in connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `each'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `each_with_index'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:211:in `connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:322:in `establish_connection'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:94:in `block in connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:279:in `with_reconnect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:93:in `connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:350:in `ensure_connected'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:207:in `block in process'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:292:in `logging'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:206:in `process'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:112:in `call'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:1320:in `block in smembers'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:37:in `block in synchronize'
App 31082 stderr:       /usr/share/ruby/monitor.rb:211:in `mon_synchronize'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:37:in `synchronize'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:1319:in `smembers'
App 31082 stderr:       /usr/local/share/gems/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:393:in `call_with_namespace'
App 31082 stderr:       /usr/local/share/gems/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:290:in `method_missing'
App 31082 stderr:       /usr/local/share/gems/gems/resque-1.25.2/lib/resque.rb:259:in `queues'
App 31082 stderr:       /usr/local/share/gems/gems/resque-1.25.2/lib/resque.rb:431:in `info'
App 31082 stderr:       /var/www/html/app.rb:29:in `block in <class:App>'

I'm trying to use Resque in a simple Sinatra app with Passenger/Apache, but get a permission error whenever Resque tries to access Redis. This same error happens with various methods, including Resque.info and Resque.enqueue, and it happens regardless of whether or not redis-server is actually running

If I write the same code in irb or a ruby script, it runs fine.

I have tried switching which users are running both apache/passenger and redis, including root.

App 31099 stdout: 
App 31082 stderr: 2015-10-01 12:23:52 - Errno::EACCES - Permission denied - connect(2):
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:122:in `connect_nonblock'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:122:in `connect_addrinfo'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:162:in `block in connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `each'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `each_with_index'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:160:in `connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/connection/ruby.rb:211:in `connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:322:in `establish_connection'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:94:in `block in connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:279:in `with_reconnect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:93:in `connect'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:350:in `ensure_connected'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:207:in `block in process'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:292:in `logging'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:206:in `process'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis/client.rb:112:in `call'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:1320:in `block in smembers'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:37:in `block in synchronize'
App 31082 stderr:       /usr/share/ruby/monitor.rb:211:in `mon_synchronize'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:37:in `synchronize'
App 31082 stderr:       /usr/local/share/gems/gems/redis-3.2.1/lib/redis.rb:1319:in `smembers'
App 31082 stderr:       /usr/local/share/gems/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:393:in `call_with_namespace'
App 31082 stderr:       /usr/local/share/gems/gems/redis-namespace-1.5.2/lib/redis/namespace.rb:290:in `method_missing'
App 31082 stderr:       /usr/local/share/gems/gems/resque-1.25.2/lib/resque.rb:259:in `queues'
App 31082 stderr:       /usr/local/share/gems/gems/resque-1.25.2/lib/resque.rb:431:in `info'
App 31082 stderr:       /var/www/html/app.rb:29:in `block in <class:App>'

原文:https://stackoverflow.com/questions/32894832
更新时间:2021-12-25 18:12

最满意答案

这似乎是Schematron任务中的一个错误。 即使任务本身位于子类加载器上,Ant任务加载Saxon XSLT处理器的方式也需要Saxon在系统类路径上。

乍一看,ValidatorFactory中的这段代码看起来足够明智:

private TransformerFactory _factory = TransformerFactoryImpl.newInstance();

(其中TransformerFactoryImpl是Saxon的TransformerFactory实现),但实际上TransformerFactoryImpl没有定义它自己的newInstance()方法,因此这是来自TransformerFactory的继承的newInstance ,它将根据javax.xml.transform.TransformerFactory的值查找合适的工厂javax.xml.transform.TransformerFactory系统属性。 Ant任务确实设置了这个系统属性

System.setProperty("javax.xml.transform.TransformerFactory",
      "net.sf.saxon.TransformerFactoryImpl");

TransformerFactory.newInstance()将在系统类加载器上查找此类,而不一定在加载schematron任务的类加载器上。

解决方法是将ValidatorFactory行120更改为简单

private TransformerFactory _factory = new TransformerFactoryImpl();

这将绕过所有的动态查找并直接实例化正确的类。 有了这个修复程序

<taskdef name="schematron" 
 classname="com.schematron.ant.SchematronTask"
 classpath="lib/ant-schematron.jar:lib/saxon9he.jar"/>

会正常工作。

我建议你向开发人员报告错误,但该项目看起来并不是特别活跃,所以你可能只需要建立自己的本地分支。


This appears to be a bug in the Schematron task. The way the Ant task loads the Saxon XSLT processor would require Saxon to be on the system classpath even if the task itself is on a subsidiary classloader.

At first glance this code in ValidatorFactory looks sensible enough:

private TransformerFactory _factory = TransformerFactoryImpl.newInstance();

(where TransformerFactoryImpl is Saxon's implementation of TransformerFactory), but in fact TransformerFactoryImpl doesn't define a newInstance() method of its own so this is the inherited newInstance from TransformerFactory, which will look up an appropriate factory based on the value of the javax.xml.transform.TransformerFactory system property. The Ant task does set this system property:

System.setProperty("javax.xml.transform.TransformerFactory",
      "net.sf.saxon.TransformerFactoryImpl");

but TransformerFactory.newInstance() will look for this class on the system classloader, not necessarily on the classloader that loaded the schematron task.

The fix would be to change ValidatorFactory line 120 to simply

private TransformerFactory _factory = new TransformerFactoryImpl();

which would bypass all the dynamic lookup and instantiate the correct class directly. With this fix in place

<taskdef name="schematron" 
 classname="com.schematron.ant.SchematronTask"
 classpath="lib/ant-schematron.jar:lib/saxon9he.jar"/>

would work correctly.

I'd suggest you report the bug to the developers, but the project doesn't look particularly active so you may just have to build your own local fork instead...

相关问答

更多
  • ant的build.xml[2022-05-14]

    Ant的概念 可能有些读者并不连接什么是Ant以及入可使用它,但只要使用通过Linux系统得读者,应该知道make这个命令。当编译Linux内核及一些软件的源程序时,经常要用这个命令。Make命令其实就是一个项目管理工具,而Ant所实现功能与此类似。像make,gnumake和nmake这些编译工具都有一定的缺陷,但是Ant却克服了这些工具的缺陷。最初Ant开发者在开发跨平台的应用时,用样也是基于这些缺陷对Ant做了更好的设计。 Ant 与 makefile Makefile有一些不足之处,比如很多人都会碰 ...
  • 究竟你想做什么? 您正在编译一堆Java代码,然后使用exec执行MyProgram 。 该文件名为MyProgram.exe吗? 或者,这是Java代码吗? 如果MyProgram是您通过javac编译的java代码,则可能需要使用运行Java Runtime Engine的任务来执行已编译的*.class文件。 我假设您有一个名为MyProgram.java Java文件,并且您想要编译它并执行MyProgram.class 。
  • 更简单的方法是将所有需要的(liquibase.jar和ojdbc7.jar)库放到一个目录中,并使用路径ID引用它们。
  • 例 项目包含以下文件: ├── build.xml ├── ivy.xml └── src ├── main │   ├── java │   │   └── org │   │   └── demo │   │   └── App.java │   └── resources │   └── log4j.properties └── test └── java └── o ...
  • 您可以使用ProjectHelper类来使用构建文件来配置项目。 如果你想检查的路径包含在一个引用中,那么你可以通过它的ID从项目中获取引用。 例如,如果你在build.xml有这样的东西: 然后,您可以使用以下代码获取Path引用: import java.io.File; import org.apache.tools.ant.Proj ...
  • 这似乎是Schematron任务中的一个错误。 即使任务本身位于子类加载器上,Ant任务加载Saxon XSLT处理器的方式也需要Saxon在系统类路径上。 乍一看,ValidatorFactory中的这段代码看起来足够明智: private TransformerFactory _factory = TransformerFactoryImpl.newInstance(); (其中TransformerFactoryImpl是Saxon的TransformerFactory实现),但实际上Transfo ...
  • 我认为这是不可能的。 ProjectHelper #parse方法的API表明Project Helper可以支持任何类型的源,包括InputStream source - XML配置的源代码。 为了向后兼容,帮助程序必须至少支持File。 助手可能支持URL, InputStream等或特殊类型。 运行修改后的代码示例 String buildXml = "build.xml"; Project p = new Project(); p.setUserProperty("ant.file", buildX ...
  • jar xmlbeans.jar必须位于类路径中。 您可以从此处下载最新版本: https : //mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans/2.6.0 build.xml正在将dir ./lib/中的其他jar添加到类路径中。 The jar xmlbeans.jar must be in the classpath. You can download the latest version from here: https://mvnr ...
  • 是不是可以将所有类文件编译到一个目录中,然后像下面那样使用复制任务来复制你想要的WSDL文件? ...
  • 我相信这是问题所在: =Profile Mgnt =]] 您的CDATA部分都未正确终止,因此您的文件根本不是有效的XML。 我想你应该: =Profile Mgnt =]]>

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。