thin

nginx, thin, and multiple hosts

独自空忆成欢 提交于 2019-12-06 05:43:42
问题 I am trying to set up multiple domains on my server running nginx + thin. For example, I would like www.domain1.com and www.domain2.com to go to different apps with different root paths to their respective apps. If you are familiar with nginx, I have posted my nginx.conf file at the bottom of this post. I was thinking I could just try having multiple server blocks, but then I ran into a problem where the server would default to choosing a random thin port and both domains went to the same app

Rails development server, PDFKit and multithread

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 02:20:20
问题 I have a rails app that uses PDFKit to render pdf versions of webpages. I use Thin as a development server. The problem is that when i'm in development mode. When I start my server with "bundle exec rails s" and I try to render any PDF the whole process gets deadlocked because when you render a PDF some extra resources like images and css are requested to the server and looks like there is a single thread. How can I configure rails development server to run multiple worker threads? Thanks a

Single thread still handles concurrency request?

故事扮演 提交于 2019-12-05 21:31:31
Ruby process is single thread. When we start a single process using thin server, why are we still able to handle concurrency request? require 'sinatra' require 'thin' set :server, %w[thin] get '/test' do sleep 2 <---- "success" end What is inside thin that can handle concurrency request? If it is due to event-machine framework, the code above is actually a sync code which is not for EM used. Quoting the chapter: "Non blocking IOs/Reactor pattern" in http://merbist.com/2011/02/22/concurrency-in-ruby-explained/ : "this is the approach used by Twisted, EventMachine and Node.js. Ruby developers

Thin LoadError: no such file to load thin_parser

丶灬走出姿态 提交于 2019-12-05 14:48:16
I have installed thin and try to do thin start , which end up with this error C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/1.9/thin_parser (LoadError) from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/thin.rb:48:in `rescue in <top (required)>' from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/thin.rb:43:in `<top (required)>' from C:/Ruby192/lib/ruby/site

Why thin behind nginx?

青春壹個敷衍的年華 提交于 2019-12-05 11:30:23
Deploying my first web app. I have been using thin, it's simple and easy. All I need is a config file. But a lot of people use nginx and place a couple thin instance behind that. Why? Why not just use thin alone? And why use nginx rather than placing 3 thin instances behind a single thin instance? Thanks Scalability is the main reason. While Thin can do SSL, serve static files, and handle large responses to slow clients, Nginx is better at all of them for any given CPU and memory footprint. Even better, Nginx can do all that transparently so that the app doesn't have implement anything to

Subdomain constraint (Rails 3) makes local server (thin) SO SLOW

我是研究僧i 提交于 2019-12-05 08:09:57
I recently added a subdomain constraint to my Rails routes file constraints(:subdomain => 'new') do devise_for :customers do get "/customers/sign_up" => "registrations#new" post "/customers" => "registrations#create" put "/customers/:id" => "registrations#update" end match '/' => 'roxy#index' namespace :roxy, :path => '/' do resources :customers resources :surveys end end In order to test the subdomain routing constraint locally, I added this line to my hosts file. 127.0.0.1 new.localhost.local Now, I test my app in my browser at the URL new.localhost.local:3000. It takes about 10 - 15 seconds

How to get ActionController::Live streaming working with Thin?

半腔热情 提交于 2019-12-05 06:09:40
Question Can you use thin with ActionController::Live to implement Server Side Events (SSE) and long polling? If so, how? Context Although the title is a repeat of How to get Rails 4 ActionController::Live streaming working with Thin and Ruby 2? And how do Thin and Puma scale with live streaming? , the OP muddied the waters by asking two questions, and this question never got answered. A number of other posts suggest you CAN use thin for Server Side Events (sse) if you start it via exec thin start --threaded : Does Heroku support ActionController::Live? and Is puma the ONLY multi-threaded

Asynchronously iterating over the response of a request using Thin and Sinatra

空扰寡人 提交于 2019-12-05 01:24:29
问题 If your response in Sinatra returns an 'eachable' object, Sinatra's event loop will 'each' your result and yield the results in a streaming fashion as the HTTP response. However, if there are concurrent requests to Sinatra, it will iterate through all the elements of one response before handling another request. If we have a cursor to the results of some DB query, that means we have to wait for all the data to be available before handling a concurrent query. I've looked at the async-sinatra

How to deploy a threadsafe asynchronous Rails app?

a 夏天 提交于 2019-12-04 21:57:27
问题 I've read tons of material around the web about thread safety and performance in different versions of ruby and rails and I think I understand those things quite well at this point. What seems to be oddly missing from the discussions is how to actually deploy an asynchronous Rails app. When talking about threads and synchronicity in an app, there are two things people want to optimize: utilizing all CPU cores with minimal RAM usage being able to serve new requests while previous requests are

Sinatra - terminate server from request

◇◆丶佛笑我妖孽 提交于 2019-12-04 14:46:02
I want to be able to terminate a Sinatra app from a request, e.g. with the following route: post '/terminate' do Thread.current.kill end Implementing it like this is a bit abrupt. I'd rather the request completed, returned an HTTP OK message, and then Sinatra shut down gracefully. Is there a hook to do this? Edit: My application is a lightweight mock server used for receiving webhook notifications. I will be using multiple servers like this on the same machine (different ports), so need to avoid any global methods of starting/stopping. My requirement is driven by the fact that each server must