jruby

Ruby daemons and JRuby - alternative options

≯℡__Kan透↙ 提交于 2019-12-30 03:27:30
问题 I have an app that I am migrating from Ruby to JRuby (due to need for better Web Service Security support via Java). One of the gems I use is daemons to create a background job. The issue is that it use fork+exec to create the background process, but thats a no-no with JRuby. So - is there an alternative gem/wrapper for creating background jobs? My current thoughts are to just call rake from a shell script and let the rake task run forever... Thanks in advance, Chris. UPDATE We are currently

What's the best way to deploy a JRuby on Rails application to Tomcat?

徘徊边缘 提交于 2019-12-29 18:03:41
问题 I'm looking at ways to deploy a Ruby on Rails app (running on JRuby) to a Tomcat instance for testing. The tomcat instance is running on a Solaris server that I can SSH to. I've looked at using Capistrano, but there doesn't seem to be a lot out there about using it to deploy to Tomcat, or even about running it under JRuby, and I keep hitting bugs in Capistrano due to the Windows/JRuby environment my PC is running (yeah, it's corporate - not my choice, but I've got to live with it). I'm using

What's the best way to deploy a JRuby on Rails application to Tomcat?

人盡茶涼 提交于 2019-12-29 18:03:13
问题 I'm looking at ways to deploy a Ruby on Rails app (running on JRuby) to a Tomcat instance for testing. The tomcat instance is running on a Solaris server that I can SSH to. I've looked at using Capistrano, but there doesn't seem to be a lot out there about using it to deploy to Tomcat, or even about running it under JRuby, and I keep hitting bugs in Capistrano due to the Windows/JRuby environment my PC is running (yeah, it's corporate - not my choice, but I've got to live with it). I'm using

How do I find my PID in Java or JRuby on Linux?

情到浓时终转凉″ 提交于 2019-12-28 05:45:11
问题 I need to find the PID of the current running process on a Linux platform (it can be a system dependent solution). Java does not support getting the process ID, and JRuby currently has a bug with the Ruby method, Process.pid. Is there another way to obtain the PID? 回答1: If you have procfs installed, you can find the process id via the /proc/self symlink, which points to a directory whose name is the pid (there are also files here with other pertinent information, including the PID, but the

Rails app with JRuby not working

蹲街弑〆低调 提交于 2019-12-25 16:59:09
问题 I have an Rails app which was created on Ubuntu. I wanted to run it on a Mac, but after installing bundles and running rails s , I get following errors: LoadError: load error: sqlite3/sqlite3_native -- java.lang.UnsatisfiedLinkError: failed to load shim library, error: dlopen(/Users/home/.rvm/rubies/jruby-1.7.4/lib/native/Darwin/libjruby-cext.dylib, 10): image not found require at org/jruby/RubyKernel.java:1054 (root) at /Users/home/.rvm/gems/jruby-1.7.4/gems/sqlite3-1.3.8/lib/sqlite3.rb:6

jRuby deployment into a subfolder in Tomcat

感情迁移 提交于 2019-12-25 16:47:35
问题 While developing a jRuby application using webbrick as the webserver, all my code is written with http://localhost:3000 as the root. When deploying to Tomcat, I create a WAR file and it creates a subfolder under the webapps/ folder: localhost:8080/project_name/ This causes a load of problems with my code. Is there anything I can do in my ruby routes.rb file to deal with this? Should I resort to using some sort of virtual host in Tomcat? 回答1: There is code in JRuby-Rack to deal with this.

Ruby ternary operator

耗尽温柔 提交于 2019-12-25 11:24:30
问题 Why aren't these two statements equivalent? defined? foo ? foo << "bar" : foo = ["bar"] if (defined? foo) then foo << "bar" else foo = ["bar"] end First statement: irb(main):001:0> defined? foo ? foo << "bar" : foo = ["bar"] => nil irb(main):002:0> foo => nil irb(main):003:0> defined? foo ? foo << "bar" : foo = ["bar"] => "expression" irb(main):004:0> foo => ["bar"] Second statement: irb(main):001:0> if (defined? foo) then foo << "bar" else foo = ["bar"] end => ["bar"] irb(main):002:0> foo =>

Is Tail Call optimization all that explains this performance difference

╄→尐↘猪︶ㄣ 提交于 2019-12-25 06:32:04
问题 I saw three different ways to write the recursive form of a Fibonacci function: With the math inline, With the math inline with result caching and one Using tail recursion with. I understand using memoization converts an O(N) algorithm to an O(1) after the answers are cached. But I fail to understand how tail call optimization can help this much. I was under the impression it might prevent a few copies or something like that. It is nearly as fast as the O(1). What is Ruby doing that makes

Creating a gem using Jruby and not Ruby

家住魔仙堡 提交于 2019-12-25 04:15:24
问题 So I was successful in writing a jruby file and reading from a jar file. I also created a seperate Ruby gem, installed it and used it successfully. I would like to write a gem using Jruby (and not ruby). When I did try to do so and after installing the gem, it gave me the following error: `require': cannot load such file -- java (LoadError) Is there a specific way to write a gem using jruby that is different from the way to write a gem usig ruby? If so, please direct me to a useful tutorial

jruby IO.popen read hangs in action when requests are made to the local dev server

大城市里の小女人 提交于 2019-12-25 04:06:47
问题 I just want to send the output of wkhtmltopdf to the user. It shouldn't be so hard. def it send_pdf "file.pdf" end def send_pdf(file) url= url_for(params) # Example: http://localhost:3000/report/it webkit= Rails.root.join('app', 'bin', 'wkhtmltopdf', 'current') cmd= "#{webkit} -q \"#{url_for(params)}\" -" data= IO.popen(cmd).read ############### HANGS HERE ################### send_data(data, type: "application/pdf", filename: file) end Why does it hang and how to fix it? 回答1: I think the clue