How to configure PUMA for SSL on JRUBY - ruby-on-rails-3

I have a jruby rails app that is working fine with Puma without SSL. According to Puma's wiki, I have to provide a certificate file and a key file. I got my cert file from GoDaddy and since I am on osx, I extracted the private key from the cert using the Keychain app. I am starting Puma using the following command:
bundle exec puma -b 'ssl://0.0.0.0:3000?key=file://Users/me/key.p12&cert=file://Users/me/server.x.ca.crt' -t 3:8
After that I get a bunch of warnings about redefined SSL constants like this one
/Users/me/.rvm/gems/jruby-1.7.1/gems/jruby-openssl-0.8.2/lib/shared/jruby-openssl.rb:16 warning: already initialized constant OPENSSL_VERSION_NUMBER
Then this message:
Puma 1.6.3 starting...
* Min threads: 3, max threads: 8
* Environment: development
IOError: sun.net.ftp.FtpProtocolException: Welcome message:
initialize at org/jruby/RubyFile.java:333
open at org/jruby/RubyIO.java:1179
open at org/jruby/RubyKernel.java:333
read at org/jruby/RubyIO.java:3611
read at org/jruby/RubyIO.java:3708
run at /Users/me/.rvm/gems/jruby-1.7.1/gems/puma-1.6.3-java/lib/puma/cli.rb:359
each at org/jruby/RubyArray.java:1612
run at /Users/me/.rvm/gems/jruby-1.7.1/gems/puma-1.6.3-java/lib/puma/cli.rb:314
(root) at /Users/me/.rvm/gems/jruby-1.7.1/gems/puma-1.6.3-java/bin/puma:10
load at org/jruby/RubyKernel.java:1046
(root) at /Users/me/.rvm/gems/jruby-1.7.1/bin/puma:1
eval at org/jruby/RubyKernel.java:1066
(root) at /Users/me/.rvm/gems/jruby-1.7.1/bin/ruby_noexec_wrapper:14
And Puma exits. The app runs on my dev machine. I am not using any FTP so I am puzzled by this error message. Any help would be greatly appreciated.

It seems that Puma 1.6.x on Jruby do not work with SSL (see the last Evan Phoenix's comment at the bottom of the page). I now use Apache as a reverse proxy to handle SSL in front of Puma.

Related

Deploying Custom Cartridges on Openshift Origin

I have created a new custom cartridge, in which I have packaged into an rpm using tito and installed using yum. This cartridge is being copied from my spec file to the /usr/libexec/openshift/cartridges directory, however, when I log into the origin home site and try to create an application my cartridge does not show up. I went digging in the ruby scripts and I found that there is a script named cartridge_cache.rb seems to be caching the cartridges it finds within the /usr/libexec/openshift/cartridges directory. I have tried to get origin to reload the cache to include my new cartridge by removing all the cache files within the /var/www/openshift/broker/cache directory then restarting the broker, but I have had no success. Is there somewhere I need to hardcode my cart name to some global variable or something ? Basically, Does anyone know how to get your custom cart to show up on the webpage for creating a new application.
UPDATE: So I ran into a slide deck that had one slide on how to install the cartridge. However, I still have had no success, but here is what I have tried since the previous post:
moved my cartridge directory from /usr/libexec/openshift/cartridges to /usr/libexec/openshift/catridges/v2
ran this command
oo-admin-cartridge -a install -s /usr/libexec/openshift/cartridges/v2/myfirstcart
which the output stated it installed the cartridge.
cleared cache with
bundle exec rake tmp:clear
restarted the openshift broker service
Also, just to make sure the cache was cleared out I went into the Rails console and ran Rails.cache.clear. And still no custom cartridge on the openshift webpage.
It works for me after cleaning cache
cd /var/www/openshift/broker
bundle exec rake tmp:clear
and restarting broker service
service openshift-broker restart
http://openshift.github.io/documentation/oo_administration_guide.html#clear-the-broker-application-cache
MCollective service on Node server (if you have separate servers for broker and node) must be restarted. e.g. with
service ruby193-mcollective restart
After that you should clear the caches on broker server e.g with
/usr/sbin/oo-admin-broker-cache --console
Then you should have new cartridges available

How can I run oink in heroku?

I'm having a problem running the oink gem on my app in Heroku. I've included it in my gemfile and gemfile.lock, uploaded those, and it installs. It even creates the oink.log (which I have no way of viewing, unfortunately). When I run
heroku run bundle exec oink --threshold=0 log/* --app my_app
I get
Running bundle exec oink --threshold=0
log/delayed_job.log log/development.log log/oink.log log/production.log log/test.log attached to terminal... up, run.3
/app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:88:in get_file_listing':
Could not find "log/delayed_job.log" (RuntimeError)
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:86:ineach'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:86:in get_file_listing'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/../lib/oink/cli.rb:59:inprocess'
from /app/.bundle/gems/ruby/1.8/gems/oink-0.9.3/bin/oink:4
from /app/.bundle/gems/ruby/1.8/bin/oink:19:in 'load'
from /app/.bundle/gems/ruby/1.8/bin/oink:19
I've tried running each of the individual files, too, and get the same result. This command runs fine on my local machine.
In my production.rb file, I have
config.logger = Hodel3000CompliantLogger.new(config.paths.log.first)
config.middleware.use( Oink::Middleware )
as configuration.
Can you enlighten me on what I'm doing wrong here? My understanding is that the logs are read only, but I don't know if that means they're only accessible through the heroku logs command. If there's a way I can see the oink.log file, too--knowing how to do that is also appreciated, or knowing how to see it in the actual Heroku log using heroku logs.
UPDATE: The configuration for oink shown above allows the commands to be run successfully on my localhost.
Thanks!
-Andrew

Rails Reporting Wrong Environment in Multi-stage Setup

Using capistrano 2.12.0, capistrano-ext 1.2.1, Rails 3.2.7 and Phusion Passenger 3.0.15.
For no logical reason, my 'playground' server has started reporting that it's actually running in development mode.
I've reinstalled things, restarted apache etc but am still stuck.
Don't really want to hardcode as I've got a production environment to think about.
In my apache conf. I've set
RailsEnv playground
There's a gist of my deploy.rb file here
Capistrano is sending to the correct location etc. so I think it's rails or passenger rather than cap.
What else can I do to get this going properly??
---- EDIT ----
I've just tested with Unicorn and it's also reporting that it's running in development mode.
Starting unicorn with the following:
unicorn -E playground -l 8000
After much experimentation, I found the root cause to be a line in one of my models:
- if Rails.env = 'development'
Obviously, this should have been a '==' not a single one.

LoadError: no such file to load -- rack/handler/glassfish

I have Successfully installed glassfish-1.0.3-universal-java, but when I run Rails Server using the command Jruby -S rails server glassfish. The output is follows:
f:\Program Files\BitNami JRubyStack\jruby\depot>Jruby -S rails s glassfish
Exiting
LoadError: no such file to load -- rack/handler/glassfish
require at org/jruby/RubyKernel.java:1033
try_require at F:/Program Files/BitNami JRubyStack/jruby/lib/ruby/gems/1.8/gem
s/rack-1.4.1/lib/rack/handler.rb:63
......
Any questions? Should I run Tomcat or Glassfish first?
You don't need to run rails server anymore, you just run glassfish.
f:\Program Files\BitNami JRubyStack\jruby\depot>glassfish
That will start up glassfish for your depot project. Check out their documentation for a little more information about this. That being said I think the glassfish project is kind of dying. From what I understand Oracle has killed glassfish (http://www.infoq.com/news/2010/04/glassfish-gem-alternatives-jruby). I would take a look at using Trinidad or Torquebox as alternatives.

Phusion Passenger ngnix.conf location

I have a Rails 3 application that uses Phusion Passenger. I install the standalone version of Passenger using the command "gem install passenger" on my Macintosh MacBook Pro. The application works fine. Now, I want to change some configurations for the ngnix server but I can not find the location of the ngnix.conf file. I have looked in /usr/local and /opt/ and /etc/. Can someone assist me in either finding or creating the ngnix.conf?
Thanks
Look for the nginx.conf file in /opt/nginx/conf
You must have su privileges to edit this file.
Remember to stop and start nginx after making your changes