rack

Devise authentication for sinatra app mounted in Rails

我怕爱的太早我们不能终老 提交于 2019-12-07 12:14:32
问题 I am using - Rails 3.2.2 Ruby 1.9.3 Devise 2.0.4 my route file looks like this: Foo::Application.routes.draw do devise_for :admins root :to => "home#index" authenticate :admin do mount Simple::App, at: '/simple' end end access under /simple needs to be authenticated. However if not signed in , access to /simple/* will be redirect to /simple/admin/sign_in instead of just /admin/sign_in which creates a redirect loop. Do I need to create a custom failure_app to correct this behavior? Thanks! 回答1

大规模机器集群-故障自动处理(二)

梦想的初衷 提交于 2019-12-07 09:08:32
本篇开始介绍具体的实现过程,为表述方便,先定义一些名词, _AutoRepairSystem: _ 故障自动维修系统, 缩写为ARS 原子操作: 任务的最小操作,机器任务通常是指重启、重装 运维人员:运维工程师= SRE = OP,系统工程师 = sys 远程管理工具: 远程控制操作物理机器的工具,如ipmi、ilo 先来看ARS的整体视图和流程图, ARS的工作流程, 故障检测: 每5分钟发起一次故障检测,获取当前时刻整个集群的故障机器列表,推送到工作流子系统 安全策略: 遍历故障机器列表,依次执行安全策略,过滤不符合要求的机器,得到一个可安全执行重启、重装的机器列表 服务离线: 遍历可安全操作的机器列表,执行服务离线 故障维修: 服务离线后,发起重启、维修操作,轮询机器状态,直至重启成功或维修完成 环境初始化: 执行环境初始化,保证机器环境符合业务需求 服务上线: 恢复服务,检查服务达到可服务状态,流程结束 接下来将介绍工作流子系统,这是所有具体操作任务执行的基础; 再依次介绍上述流程中的关键环节: 服务上下线,故障检测,安全策略,维修工具及SLA; 然后通过一个线上例子,说明整体的工作流程; 最后分享系统上线后的运行数据。 2.1 工作流子系统 工作流最基本的功能,是驱动一系列预定义任务顺序执行,达到明确的结束状态;在机器故障自动处理这个问题域里,对工作流还有闭环

NameError: undefined local variable or method `app'

与世无争的帅哥 提交于 2019-12-07 06:14:05
问题 The controller spec I created fails with the following error message: NameError: undefined local variable or method `app' for \ #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1:0x00000004424880> ... # spec/controllers/sessions_conroller_spec.rb require 'spec_helper' describe SessionsController do before do @user = User.gen! end describe "#create" do context "when sending valid email and password" do it "renders a json hash ..." do post :create, email: @user.email, password: @user

Passenger Rack app 'cannot infer basepath'

吃可爱长大的小学妹 提交于 2019-12-07 01:07:26
问题 This question was migrated from Server Fault because it can be answered on Stack Overflow. Migrated 9 years ago . I have a simple config.ru file for my Sinatra app. require 'sinatra' require 'app' run Sinatra::Application However, Passenger is failing with the error no such file to load -- app . I've tried using the 1.9 method require_relative but that now causes the error cannot infer basepath . I'm currently using the very hacky require File.join(File.dirname(__FILE__), 'app' ) , which is

Very slow: ActiveRecord::QueryCache#call

自闭症网瘾萝莉.ら 提交于 2019-12-06 18:48:01
问题 I have an app on heroku, running on Puma: workers 2 threads_count 3 pool 5 It looks like some requests get stuck in the middleware, and it makes the app very slow (VERY!). I have seen other people threads about this problem but no solution so far. Please let me know if you have any hint. ! ! 回答1: I work for Heroku support and Middleware/Rack/ActiveRecord::QueryCache#call is a commonly reported as a problem by New Relic. Unfortunately, it's usually a red herring as each time the source of the

Rails 3 middleware modify request headers

廉价感情. 提交于 2019-12-06 17:39:43
问题 My setup: Rails 3.0.9, Ruby 1.9.2 I am working on my first middleware app and it seems like all of the examples deal with modify the response. I need to examine and modify the request headers in particular, delete some offending headers that cause a bug in Rack 1.2.3 to choke. Here's the typical hello world Rack app. my_middleware.rb class MyMiddleware def initialize(app) @app = app end def call(env) @status, @headers, @response = @app.call(env) [@status, @headers, @response] end end Does

Anyone using JRuby-Rack with Rails 3?

蹲街弑〆低调 提交于 2019-12-06 11:53:15
Is anyone else out there running Rails 3 and JRuby-Rack, or Jetty and Rails 3? Any trick to it? I'm going insane with some debugging, and at this point I just want to know that it's possible. These instructions work for me: http://mathias-biilmann.net/2010/2/jruby-and-rails-3-beta-step-by-step ranjib i am using jetty-rails + rails3 for a couple of projects. jetty-rails need to be fixed , require "activesupport" need to be changed to require "active_support" (for activesupport 3.0.3) and you have also do 'require "active_support/all"' to include hash extensions (otherwise symbolize! & reverse

Sinatra doesn't show exceptions in log file

天大地大妈咪最大 提交于 2019-12-06 11:52:53
I'm coming from Rails to sinatra, and I have some problems using logging. I have a Sinatra app, that does it's logging like so: configure do Logger.class_eval { alias :write :'<<' } logger = Logger.new("log/#{settings.environment}.log") use Rack::CommonLogger, logger end All requests are logged properly, I see sth like 127.0.0.1 - - [25/May/2013 10:34:21] "GET / HTTP/1.1" 200 30 0.0021 127.0.0.1 - - [25/May/2013 10:34:22] "GET /favicon.ico HTTP/1.1" 404 18 0.0041 Inside the log files. But I also want to log application errors to the logfile. When I start my app in production env with RACK_ENV

Sinatra: three logs

大憨熊 提交于 2019-12-06 11:47:14
I'm using a very simple Sinatra app that works well. However, every log message is repeated three times. I can bring that down to two by disabling the Sinatra logging with disable :logging but I still have two. The messages are slightly different, so I gather they are coming from Rack and somewhere else in the stack too. How do I completely disable logging of successful web requests? Rack is adding own logging as a middleware try to run rackup -E none This removes one log entry. The second one is sinatra native which you've already disable. And the third one is Rack::Lint logging if I remember

Rails 3 request dispatch cycle

夙愿已清 提交于 2019-12-06 11:10:48
问题 I was looking at the rails 3 architecture in order to understand the process of dispatching a request . The whole process is quite simple. Application is a rack application which finally delegates its call message to the call method of ActionDispatch::Routing::RouteSet which dispatches appropriate action of necessary controller. It takes controller and action names from the hash stored in rack env by the key "action_dispatch.request.path_parameters". So the question is: Who sets this hash?