EzDevInfo.com

torquebox

TorqueBox Ruby Platform TorqueBox: Home

Java Deployment in TorqueBox

I am new to TorqueBox. I have created one RESTEasy app which is currently running on tomcat. Now I want to deploy it in TorqueBox. For that I have created on yml file in apps folder of torquebox. The content of file is

---
application: 
  root: C:/torqueApp/java/RESTEasyTorque
  env: development 
web: 
  context: /hellojava

My problem is when i start server it doesn't deploy my app. What should i do?


Source: (StackOverflow)

Where can I find developer output from Rails application deployed to Torquebox

I have a JRuby on Rails application, which is usually deployed as war to Tomcat. In development mode we use either WEBrick or trinidad (usually first). Now we are considering using Toquebox.

I was able to deploy app using Torquebox, but I wonder where can I find development logs (things like request/response details, executed SQL queries etc). I got used to that stuff. JBoss'es console, boot.log and server.log don't contain those - only torquebox specific logging.

Thanks


Source: (StackOverflow)

Advertisements

Is there an Amazon EC2 AMI for TorqueBox 2.x

I've been using TorqueBox for several months and was wondering if anyone knew of a public TorqueBax AMI for Amazon web services for the 2.x verson of TorqueBox.

I have searched the Internet several times, but to date have only come across what appears to be a TorqueBox 1.x version.


Source: (StackOverflow)

Bad performace of torquebox on EC2

I am going to integrate Torquebox.
I have read the post about rails from here

I have tested the source code for hello world application in rails on EC2 using Apache Benchmark tool. It gives me the result of 23 request per sec. As in that post they have mention around 600 request per sec. Why I have got this result? Is there any additional configuration in torquebox server?


Source: (StackOverflow)

Attach to torquebox logger

How do I re-use the existing Torquebox/JBoss logger from (for example) a scheduled job?

If I do

@logger = TorqueBox::Logger.new()
@logger.debug "hello"

... it goes nowhere. I've also tried TorqueBox::Logger.new("my_rails_app_name") with the same result.


Source: (StackOverflow)

Using JRuby to Replace JSP in a Java EE Servlet Webapp

I have been playing with the new torquebox (JBOSS) app server and like what I see so far however the ruby apps seem to be segregated from the java webapps. It is like they run in silos as separate webapps and blending them is obscure although I read that sessions can be shared... which is cool.

I have a conventional web-app built in Java EE Servlet JSP style and I want to be able to use ruby as my presentation layer logic instead of the JSP that is being used.

I should be able to run ruby resource from a web request context. Much like apache mod_ruby kicks in to process rhtml... ( goal: get tomcat or JBoss to do this so trinidad or torquebox)

Example would be that I could replace HelloWorld.jsp ( that could call my java packages...) with HelloWorld.rhtml or .rb? and it could also call my java classes because it is JRuby...

As of now I can create RoR apps separate and sinatra but... I want ruby in the Java webapp not Java in the ruby webapp.

Does anyone know if what I am asking is currently possible with Torquebox or Trinidad?


Source: (StackOverflow)

Using Torquebox to send messages to the browser

So our team has recently implemented torquebox into our jruby on rails applications. The purpose of this was to be able to receive queue/topic messages from an outside source which is streaming live data.

We have setup our queues/topics and they are receiving the messages without an issue. The next step we want to take is to get these messages on the browser.

So we started to look into leveraging the power of stomp. But we have come across some issues with this. It seems from the documentation that the purpose of using stomp + websockets is to receive messages from the client-side and push those messages to other clients. But we want to receive messages on our queues, and then push these messages to the client-side using websockets. Is this possible? Or would we have to implement a different technology such as Pusher or socket.io to get the queue/topic messages to the browser?

Thanks.


Source: (StackOverflow)

The best way to insert large amount of messages into TorqueBox message queue

what's the fastest way to push millions of messages into HornetQ? I have these both approaches:

1.) My current code, reuses one session for all messages, ca. 2.200 messages per second

time = Benchmark.realtime do
  queue.with_session(:tx => false) do |session| 
    1_000_000.times do
      payload = Array.new(32){rand(36).to_s(36)}.join
      session.publish(queue, payload, queue.normalize_options(:persistent => false))
    end
  end
end
puts "Time elapsed #{time} seconds ..."

2.) The optimized way, but it hangs after the first 30k messages, til then 9.000 messages per second

time = Benchmark.realtime do
  queue.with_session(:tx => false) do |session|
    options = queue.normalize_options(:persistent => false)
    producer = session.instance_variable_get('@jms_session').create_producer(session.java_destination(queue))
    1_000_000.times do
      payload = Array.new(32){rand(36).to_s(36)}.join
      message = TorqueBox::Messaging::Message.new(session.instance_variable_get('@jms_session'), payload, options[:encoding])

      message.populate_message_headers(options)
      message.populate_message_properties(options[:properties])

      producer.disable_message_id = true
      producer.disable_message_timestamp = true

      producer.send( message.jms_message,
        options.fetch(:delivery_mode, producer.delivery_mode),
        options.fetch(:priority, producer.priority),
        options.fetch(:ttl, producer.time_to_live)
      )
    end
  end
end
puts "Time elapsed #{time} seconds …"

The question is, why does the second snippet hang after the 30k? What would you recommend for massive inserts into HornetQ?

Regards, Chris


Source: (StackOverflow)

Torquebox: unable to work with SLIM

How do I launch a simple Sinatra app with Torquebox and slim as a html rendering engine?

Plain html works fine... whenever I use slim the server fails:

HTTP Status 500 - org.jruby.exceptions.RaiseException: (NoMethodError) undefined method join' for #<String:0xf94f510>

I am dying to get torquebox up and running!

config.ru:

require 'rubygems'
require 'sinatra'
require File.expand_path '../hello.rb', __FILE__
run Sinatra::Application

hello.rb:

get '/' do
  File.read(File.join('public', 'index.html'))
end

get '/kalli' do
  slim :some_file
end

Source: (StackOverflow)

Proxy requests to virtual host in by path prefix

I'm running multiple Rails applications on TorqueBox. Each application is mounted on a different web context, e.g., localhost:8080/app1 and localhost:8080/app2 (configured via TorqueBox). Apache is configured to accept requests to app1.domain.com and app2.domain.com via virtual hosts. However, I'm running into problems where some application paths (form submission paths and others) expect to be preceeded by /app1, e.g., http://app1.domain.com/app1/rest/of/path instead of the correct http://app1.domain.com/rest/of/path.

How can I configure Apache so that the requests to http://app1.domain.com/app1/... are made to the correct path (i.e., without the leading /app1)? I've tried doing this with redirects but that doesn't work since they force a GET request and the POST data is lost in the process.

This is my current Apache config:

LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
ProxyRequests Off
ProxyPreserveHost On
NameVirtualHost *:80

<VirtualHost *:80>  # There are multiple vhosts like this one, for different apps.
    ServerName app1.domain.com
    ProxyPass / http://127.0.0.1:8080/app1/
    ProxyPassReverse / http://127.0.0.1:8080/app1/
</VirtualHost>

Source: (StackOverflow)

Paperclip: undefined method `exitstatus' for nil:NilClass

I'm trying to use paperclip to handle image file uploads to S3. In my user model:

validates_attachment :avatar, :content_type => { :content_type => ["image/jpg", "image/png"] }, :size => { :in => 0..500.kilobytes }

When uploading the image I get the following error:

Command :: identify -format %wx%h "C:/Users/Tom/AppData/Local/Temp/rails121215-6332-1o1oxtk-30333.png[0]"
Completed 500 Internal Server Error in 277ms

NoMethodError (undefined method `exitstatus' for nil:NilClass)

Similar issues here suggest that there is a problem running some of the imageMagick commands. However, I've set Paperclip.options[:command_path] and this makes no difference. Imagemagick is also on the path and if I execute identify -format %wx%h "C:/Users/Tom/AppData/Local/Temp/rails121215-6332-1o1oxtk-30333.png[0]" in a command prompt I get 50x64 returned. Additionally I'm using torquebox and in the torquebox window I get the following printed for some reason: 14:59:11,205 INFO [stdout] (Thread-144) 50x64 so the command is clearly being executed in some fashion.

I've also tried using Cocaine::CommandLine.runner = Cocaine::CommandLine::BackticksRunner.new but this just results in the following error: Errno::EINVAL (Invalid argument - =ExitCode)

I'm using JRuby with Torquebox if it makes any difference.

Here is the trace:

cocaine (0.4.2) lib/cocaine/command_line.rb:80:in `run'
paperclip (3.3.1) lib/paperclip/helpers.rb:31:in `run'
paperclip (3.3.1) lib/paperclip/geometry.rb:23:in `from_file'
activesupport (3.2.8) lib/active_support/core_ext/kernel/reporting.rb:43:in `silence_stream'
paperclip (3.3.1) lib/paperclip/geometry.rb:22:in `from_file'
paperclip (3.3.1) lib/paperclip/thumbnail.rb:35:in `initialize'
paperclip (3.3.1) lib/paperclip/processor.rb:33:in `make'
paperclip (3.3.1) lib/paperclip/attachment.rb:410:in `post_process_style'
org/jruby/RubyArray.java:1615:in `each'
org/jruby/RubyEnumerable.java:830:in `inject'
paperclip (3.3.1) lib/paperclip/attachment.rb:409:in `post_process_style'
paperclip (3.3.1) lib/paperclip/attachment.rb:402:in `post_process_styles'
org/jruby/RubyHash.java:1186:in `each'
paperclip (3.3.1) lib/paperclip/attachment.rb:401:in `post_process_styles'
paperclip (3.3.1) lib/paperclip/attachment.rb:394:in `post_process'
activesupport (3.2.8) lib/active_support/callbacks.rb:406:in `_run__1796712306__avatar_post_process__1832820880__callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:390:in `_run_avatar_post_process_callbacks'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
paperclip (3.3.1) lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
paperclip (3.3.1) lib/paperclip/attachment.rb:393:in `post_process'
activesupport (3.2.8) lib/active_support/callbacks.rb:406:in `_run__1796712306__post_process__1832820880__callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:390:in `_run_post_process_callbacks'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
paperclip (3.3.1) lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
paperclip (3.3.1) lib/paperclip/attachment.rb:392:in `post_process'
paperclip (3.3.1) lib/paperclip/attachment.rb:107:in `assign'
paperclip (3.3.1) lib/paperclip.rb:196:in `avatar='
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activerecord (3.2.8) lib/active_record/attribute_assignment.rb:85:in `assign_attributes'
org/jruby/RubyHash.java:1186:in `each'
activerecord (3.2.8) lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
activerecord (3.2.8) lib/active_record/persistence.rb:215:in `update_attributes'
activerecord (3.2.8) lib/active_record/transactions.rb:295:in `with_transaction_returning_status'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
torquebox-transactions (2.1.2) lib/torquebox/active_record_adapters.rb:37:in `transaction'
activerecord (3.2.8) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.2.8) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.2.8) lib/active_record/persistence.rb:214:in `update_attributes'
app/controllers/users_controller.rb:11:in `update'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.2.8) lib/active_support/callbacks.rb:418:in `_run__841617381__process_action__1679400720__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:225:in `_conditional_callback_around_260'
activesupport (3.2.8) lib/active_support/callbacks.rb:326:in `around'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:314:in `_callback_around_23'
activesupport (3.2.8) lib/active_support/callbacks.rb:224:in `_conditional_callback_around_260'
activesupport (3.2.8) lib/active_support/callbacks.rb:417:in `_run__841617381__process_action__1679400720__callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:390:in `_run_process_action_callbacks'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.8) lib/action_controller/metal.rb:246:in `action'
org/jruby/RubyProc.java:258:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `call'
org/jruby/RubyArray.java:1615:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
sass (3.1.20) lib/sass/plugin/rack.rb:54:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `call'
org/jruby/RubyKernel.java:1197:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
torquebox-web-2.1.2 (java) lib/torquebox/session/servlet_store.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
activesupport (3.2.8) lib/active_support/callbacks.rb:408:in `_run__2062687110__call__1832820880__callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:390:in `_run_call_callbacks'
org/jruby/RubyBasicObject.java:1698:in `__send__'
org/jruby/RubyKernel.java:2097:in `send'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
org/jruby/RubyBasicObject.java:1704:in `__send__'
org/jruby/RubyKernel.java:2101:in `send'
railties (3.2.8) lib/rails/railtie/configurable.rb:30:in `method_missing'

Source: (StackOverflow)

Chef fails when trying to deploy a Torquebox app on EC2

I'm pretty new to Chef/ops in general but I'm trying to deploy on EC2 and I keep running into this error. The stack trace file mentioned in the error does not exist so that's making it kind of hard to debug the problem. Also, whenever Chef fails, the permission on my EC2 box gets denied and I have to spin up a new instance. For reference, the original source of this file is from here: http://janitor.se/blog/2013/07/04/easier-neo4j-dot-rb-deployments-with-chef-plus-capistrano-plus-torquebox/

The error looks like this:

  * script[install torquebox backstage] action run
    - execute "bash"  "/tmp/chef-script20131011-2067-1phzfkw"

[2013-10-11T03:47:51+00:00] ERROR: Running exception handlers
[2013-10-11T03:47:51+00:00] ERROR: Exception handlers complete
[2013-10-11T03:47:51+00:00] FATAL: Stacktrace dumped to /tmp/chef-solo/chef-stacktrace.out
Chef Client failed. 71 resources updated
[2013-10-11T03:47:51+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.

My recipe file - torquebox.rb:

download_file = File.join("/tmp", File.basename(node.torquebox.download_url))

remote_file download_file do
  source  node.torquebox.download_url
  mode 00644
  action :create_if_missing
  notifies :run, "script[install-torquebox]", :immediately
end

script "install-torquebox" do
  Chef::Log.info("Installing torquebox zip file...")
  user 'torquebox'
  interpreter "bash"
  code <<-EOH
  unzip -o #{download_file} -d /opt/torquebox/
  ln -s /opt/torquebox/torquebox-2.3.2 /opt/torquebox/current
  EOH
  notifies :run, "execute[change ownership to torquebox]"
  not_if do
    File.exists? "/opt/torquebox/torquebox-2.3.2"
  end
  # not_if do
  #    File.exists? "/opt/torquebox/torquebox-2.2.0"
  #  end
  #action :nothing
end


template "/etc/profile.d/torquebox.sh" do
  source "torquebox.sh.erb"
  mode 00644
  owner 'root'
  variables(
    :jboss_user =>  node[:torquebox_env][:jboss_user],
    :torquebox_home => node[:torquebox_env][:home],
    :jboss_pidfile => node[:torquebox_env][:jboss_pidfile],
    :jboss_console_log => node[:torquebox_env][:jboss_console_log],
    :jboss_config => node[:torquebox][:configuration_file],
    :jruby_opts => node[:torquebox_env][:jruby_opts],
    :java_environment_file => node[:java][:java_environment]
  )
  notifies :restart, "service[jboss-as-standalone]"
end


# install torquebox backstage
#
execute "change ownership to torquebox" do
  user "root"
  cwd "/opt"
  Chef::Log.info("changing ownership for torquebox")
  command "chown -Rv 1000.1000 /opt/torquebox"
  notifies :run, "script[install torquebox backstage]"
  action :nothing
end

script "install torquebox backstage" do
  Chef::Log.info("Installing torquebox backstage file...")
  interpreter "bash"
  user "torquebox"
  cwd "/opt/torquebox"
  code <<-EOH
  export TORQUEBOX_HOME=/opt/torquebox/torquebox-2.3.2
  export JAVA_HOME=/opt/jdk7/
  export JBOSS_HOME=$TORQUEBOX_HOME/jboss
  export JRUBY_HOME=$TORQUEBOX_HOME/jruby
  export PATH=$JBOSS_HOME/bin:$JRUBY_HOME/bin:$JAVA_HOME/bin:$PATH
  EOH
  # jruby -S gem install torquebox-backstage
  # jruby -S gem install ruby-shadow
  # jruby -S backstage deploy
  not_if do
    File.exists? "/opt/torquebox/current/jruby/bin/backstage"
  end
end

directory '/opt/apps/' do
  owner "torquebox"
  group "torqubox"
  mode 00755
  action :create
  not_if do
    File.exists? "/opt/apps/"
  end
end

directory "/etc/jboss-as" do
  owner "root"
  group "root"
  mode 00755
  action :create
  not_if do
    File.exists? "/etc/jboss-as"
  end
end

directory "/var/log/jboss-as" do
  owner "torquebox"
  group "torquebox"
  mode 00755
  action :create
  not_if do
    File.exists? "/var/log/jboss-as"
  end
end

template "/etc/init.d/jboss-as-standalone" do
  source "jboss-as-standalone.sh.erb"
  variables(:environment_file => node[:torquebox][:environment_file])
  mode 00755
  owner 'root'
  notifies :restart, "service[jboss-as-standalone]"
end


service "jboss-as-standalone" do
  supports :status => true, :restart => true, :stop => true, :start => true
  action [ :enable, :start ]
end

#if clustered then if cluster name is staging_cluster, so proxy name will be staging_cluster_proxy
#so for every cookbook, it should be paired with two of them
proxy_nodes = []
clustered_nodes = []

Chef::Log.warn("clustered status #{node[:torquebox][:clustered]}")
if node[:torquebox][:clustered]
  clustered_nodes =  search(:node, "roles:#{node[:torquebox][:cluster_name]}")
  proxy_nodes = search(:node, "roles:#{node[:torquebox][:cluster_name]}_proxy")

  template "/opt/torquebox/current/jboss/standalone/configuration/standalone-ha.xml" do
    source "standalone-ha.xml.erb"
    variables(:node_name => node.name, :node_ipaddress => node.ipaddress, :cluster_name => node[:torquebox][:cluster_name], :clustered_nodes => clustered_nodes, :proxy_nodes => proxy_nodes )
    mode "0644"
    notifies :restart, "service[jboss-as-standalone]"
  end
end

if proxy_nodes.count == 0 and node[:torquebox][:clustered] == true
  Chef::Log.warn("There is no proxy defined, cluster may not function")
end

if !node[:torquebox][:clustered]
  template "/opt/torquebox/current/jboss/standalone/configuration/standalone.xml" do
    source "standalone.xml.erb"
    variables(:node_name => node.name, :node_ipaddress => node.ipaddress)
    mode "0644"
    notifies :restart, "service[jboss-as-standalone]"
  end
end

template "/opt/torquebox/current/jboss/bin/standalone.conf" do
  source "standalone.conf.erb"
  mode "00644"
  owner 'torquebox'
  variables(:jboss_config => node[:torquebox][:configuration_file])
  notifies :restart, "service[jboss-as-standalone]"
end

cookbook_file "/etc/jboss-as/jboss-as.conf" do
  source "jboss-as.conf"
  mode 00644
  owner 'root'
end


# NGINX!

# this enables our site, kinda like a2ensite
execute 'enable-site' do
  command "ln -sf /etc/nginx/sites-available/#{node[:server_name]} /etc/nginx/sites-enabled/#{node[:server_name]}"
  notifies :restart, 'service[nginx]'
end

# Our configuration template. Take a look at templates/nginx.conf.erb to see what's going on.
template "/etc/nginx/sites-available/#{node[:server_name]}" do
  source 'nginx.erb'
  owner 'root'
  group 'root'
  mode 0644
  notifies :run, "execute[enable-site]", :immediately
  variables(
     server_name: node.server_name
   )
end

service 'nginx'
service 'jboss-as-standalone'

Source: (StackOverflow)

How can I trace the downtime reported by Newrelic

I am getting downtime alert for web application with different failure messages. these all are 2-3 mins downtime. This downtime is random 2-3 times in a day.

failure messages

  • problem parsing the HTTP response, no further detail available.
  • connection error (Connection refused)
  • timeout after 30 seconds
  • 404 status

Application info

Ruby on Rails 3.2.14
running torquebox server with jruby [ http://torquebox.org/ ]
jruby 1.7.4 (1.9.3p392)

how can I trace the problem of these downtime, so that I can get where is the issue


Source: (StackOverflow)

Duplication of context in path for a Rails app on TorqueBox with Apache ReverseProxy

I am struggling with a scenario where I have several applications to run on a singular TorqueBox instance. When defining an app and deploying it to a root ("/") context within config/torquebox.yml the application executes properly with no apparent problems. At first I believed that this was a problem with Apache reverse proxy, but now believe it is likely an issue with Rails and/or TorqueBox, yet I can't find a clear answer or reason for the issue.

This configuration is as follows:

config/torquebox.yml contains:

web:
  context: /

Apache's httpd virtual host config for proxy is:

ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/

With this I can visit http://sub.domain.tld/, with posts and posts/new routes just fine. This is by roughly following the example here (only modifications I've performed are the ones to get reverse proxy working).

But when I switch gears and run it with a context of torquebox_test_rails_production things start to get really strange. I am left to believe that there is something wrong where rails will append a duplicate copy of the context onto the path for some reason. To explain:

I change config/torquebox.yml to:

web:
  context: /torquebox_test_rails_production

and Apache's httpd virtual host conf to:

ProxyPass / http://127.0.0.1:8080/torquebox_test_rails_production/
ProxyPassReverse / http://127.0.0.1:8080/torquebox_test_rails_production/

When I do this, http://sub.domain.tld/ still loads okay, but then when I go to posts, I notice (in log/production.log) a failed GET request:

INFO -- : Started GET "/torquebox_test_rails_production/torquebox_test_rails_production/stylesheets/application.css"
FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/torquebox_test_rails_production/stylesheets/application.css"):
  actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.1.1) lib/rails/engine.rb:514:in `call'
  railties (4.1.1) lib/rails/application.rb:144:in `call'

As you can note, it duplicates the context there on the path.

At this point the URL is still correct with simply http://sub.domain.tld/posts, but then when I click "New Post" in the scaffolded test, the app then attempts to redirect the browser to http://sub.domain.tld/torquebox_test_rails_production/posts/new. Obviously this redirection / duplication should not be occurring. Within the log I now see:

INFO -- : Started GET "/torquebox_test_rails_production/torquebox_test_rails_production/posts/new"
FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/torquebox_test_rails_production/posts/new"):
  actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.1.1) lib/rails/engine.rb:514:in `call'
  railties (4.1.1) lib/rails/application.rb:144:in `call'

One other thing that I attempted here was to add config.relative_url_root to the config. I did this via both trying the env variable of:

RAILS_RELATIVE_URL_ROOT="/torquebox_test_rails_production"

and setting it in config/environments/production.rb to:

config.relative_url_root = "/torquebox_test_rails_production"

I would assume that this should be set itself via the context setting and therefore its purpose, but I thought it was worth a try.

I also took a cue from this question which seemed to be identical to mine, but eliminating context from torquebox.yml and just having the hostname did not solve the issue either. Instead, it seems to have eliminated the doubling of the context to path, BUT I end up with still the following error in log/production.log:

INFO -- : Started GET "/torquebox_test_rails_production/posts"
FATAL -- : 
ActionController::RoutingError (No route matches [GET] "/torquebox_test_rails_production/posts"):
  actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.1.1) lib/rails/engine.rb:514:in `call'
  railties (4.1.1) lib/rails/application.rb:144:in `call'

I then also attempted to define config.relative_url_root in production.rb as noted earlier with precisely the same result as just noted in terms of the error.

Any idea as to what may be happening here to provoke this behavior?


Source: (StackOverflow)

How do gems built for java work? Getting error install torquebox gem

I'm clearly missing something here. I'm trying to install the torquebox gems and am running into this error (on a mac):

gem install torquebox-server --pre --source http://torquebox.org/2x/builds/LATEST/gem-repo/    

Could not find a valid gem 'torquebox-server' (>= 0), here is why:
          Found torquebox-server (2.x.incremental.424), but was for platform java

I have jruby installed, version 1.6.3. It's in my path. I don't understand the above error. If you need any more info let me know.


Source: (StackOverflow)