I'm getting this error when I deploy my Sinatra app with Passenger and Apache:
Exception NoMethodError in application (undefined method `call' for nil:NilClass)
I can start the app with
ruby myapp.rb
or as a rack app with
ruby config.ru
and there are no problems. Any ideas why this only happens with Passenger?
A bit late to the party but I just had this happen for me. Turns out I needed to tell Sinatra not to "run" the app.
configure do
set :run, false
# ...
end
From the Sintara settings doc:
run - if enabled, Sinatra will handle starting the web server, do not enable if using rackup or other means.
Here is a list of the available settings for Sinatra
Good luck!
Related
I am running a Sinatra application locally.
Ever since I installed Thin, my Sinatra app always uses it as the web server. However, I have been having performance issues with Thin serving the large amount of static files required by my application, and I would like to switch to either Mongrel or WEBrick.
I cannot seem to figure out how to switch my application over to Mongrel or WEBrick. Even when I put require 'mongrel' or require 'webrick' at the top of my app.rb, upon a ruby app.rb, Sinatra still starts with Thin.
So, my question is: how do you specify the web server for Sinatra to use in development mode? Also, how could I do so in production mode?
You can set the server Sinatra uses with the :server configuration setting:
set :server, 'webrick' # or thin, mongrel
In production, it is much better to use a more sophisticated server like Phusion Passenger or Unicorn, since they have better performance than Thin, Mongrel, or WEBrick. If you choose Passenger or Unicorn, you would not configure the server within your Sinatra application file itself, but instead typically configure it separately using a Rackup config.ru file.
"Ruby on Rails Server options" is aimed at Rails applications, but is still very relevant for Sinatra apps.
When I start a program which uses EventMachine, the vmc start does not return whether it succeed or not. It seems just time out.
But,I do see "the server started" in my log file. So I am wondering what is proper way to use EventMachine in cloud foundry?
Eventmachine does work in Cloud Foundry, it's a dependency on thin which if included in a project can be used to serve Rack / Rails apps.
I know this is probably a stupid question. But I created a .rb file with Sinatra framework and I am not sure how to "deploy" it. When I posted the file on the server I just get a simple text file that reads back my code. It works great when I run it with Sinatra.
Thanks in advance!
It looks like your web server (Apache?) is just serving you with your Ruby script (that is a text, ASCII file) instead of running it (that is: instead of passing it through the Ruby interpreter).
Hence:
Is the Ruby interpreter installed on your server?
Is your web server configured to run Ruby scripts (files terminating with ".rb")
through the Ruby interpreter?
And, is Sinatra itself installed on your web server?
Anyway, Ruby applications (Rails, Sinatra, Padrino) are usually deployed to a server using GIT. Have a look at Heroku and Engine Yard.
Also, there are tools specifically designed to help the developer in deploying Ruby applications. Have a look at Capistrano or Vlad and/or Google for "how to deploy a sinatra application".
For Sinatra/Rails/etc, most people use a Webserver (ie Apache, Nginx, etc) AND an Application Server (Thin, Passenger, Unicorn). For a simple app these can live on the same host. The webserver manages the incoming traffic and the application server executes the ruby code and passes results to the webserver.
When you execute ruby app.rb to run your Sinatra application, you're actually loading up WEBrick which is an application server. Since your development machine is local, you can access it directly at localhost:3000 or some similar address.
Look into tutorial on setting up your webserver with Thin, it's one of the easier ones to work with. When/if you outgrow it, then look into Unicorn.
I used to be able see http requests made for sinatra in the window I started my sinantra application from.
I think that after sinatra upgrade I cannot see them any more and I don't know how to make it so. I don't need to log them into a file.
set :logging, true didn't help
ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32]
rack (1.4.0)
rack-protection (1.2.0)
sinatra (1.3.2)
sinatra-advanced-routes (0.5.1)
sinatra-reloader (0.5.0)
sinatra-sugar (0.5.1)
This is a bug introduced in Sinatra 1.3.2. The commit that introduced it was intented to fix another bug where the logging was being done twice in certain circumstances, but obviously isn't quite right.
This request logging is done by using the Rack::CommonLogger middleware component, which is now only added in certain cases. The fix/workaround is to simply add it yourself. Add
use Rack::CommonLogger
to the top of your application file (after requiring Sinatra). Note that you might end up with the original problem of seeing requests logged twice in some situations (e.g. if your deployment setup is different from your development setup).
I've decided to go with Apache as the http server in front of my play app. The server team at my company says they installed Apache and Python and play on the target server. I'm code complete, so here's where I don't know what to do next.
How do i "compile" my play java app?
What folders do I deploy, which ones do I not deploy?
Where on the target server hard drive do I place the webapp I'm deploying?
How do i tell apache where I deployed the play webapp to on the disk?
How do I make it so that apache and play are now always running and don't require I be logged in on the target server?
Yeah I'm new to linux
Please help I'm lost.
Thanks in advance
Josh
Read the Preparing for production section before anything else.
How do i "compile" my play java app?
Play does that for you when you laucnh play start. However you can use the play precompile command before starting the app.
What folders do I deploy, which ones do I not deploy?
app, conf and public. You might have some 3rd party lib dir too.
Where on the target server hard drive do I place the webapp I'm deploying?
I don't think it really matters.
How do i tell apache where I deployed the play webapp to on the disk?
Apache act as a reverse proxy (forwards every requests to your app and serves the reponses back to client). For this you need to edit the apache's httpd.conf
How do I make it so that apache and play are now always running and don't require I be logged in on the target server?
You need to start the apps as daemon threads which I think apache does by default. the command play start should run play in the background.