rack

Websocket header missing

故事扮演 提交于 2019-12-02 22:44:22
I'm using the 'faye' gem with Rails 3.2.13. In development I'm running faye on localhost:9292 and my app on localhost:3000. I'm able to activate pop-up windows with a curl request from the command line but I can't establish a connection from within my app. The error I'm getting in my console is: WebSocket connection to 'ws://localhost:9292/faye' failed: Error during WebSocket handshake: 'Upgrade' header is missing I am trying to define a header for faye in my application.js file: $(function() { var faye = new Faye.Client("http://localhost:9292/faye"); faye.setHeader("Access-Control-Allow

Why does Foreman not output some things until I press Control-C?

亡梦爱人 提交于 2019-12-02 22:17:10
I just got into rails programming and it looks like there are two programs I can use to run my project locally: rackup and foreman. One difference I noticed is that foreman will not output some things that I would expect to see and I would see if I ran rackup instead, until I press ctrl+c to close the server. Then all those messages appear, as if they were being hidden. Is there a reason for this? How can I get foreman to be more verbose? If you are not seeing any output from your program, there is a likely chance that it is buffering stdout. Ruby buffers stdout by default. you can fix this by

Proc throws error when used with do end [duplicate]

▼魔方 西西 提交于 2019-12-02 06:52:59
问题 This question already has answers here : Code block passed to each works with brackets but not with 'do'-'end' (ruby) (3 answers) Closed 5 years ago . This doesn't work: run Proc.new do |env| [200, { "Content-Type" => "application/json; charset=UTF-8" }, ["{\"name\":\"Rack App\"}"]] end But this does: run Proc.new { |env| [200, { "Content-Type" => "application/json; charset=UTF-8" }, ["{\"name\":\"Rack App\"}"]] } Any ideas, why its throwing error when used with do..end? Error I am getting:

Apartment current_tenant resets to 'public' after failed devise login

半城伤御伤魂 提交于 2019-12-02 05:34:32
问题 I use Devise for authentication and Apartment for multi-tenancy support on a SAAS app. After a failed login, devise "redirects" to the login page (Users::SessionsController#new) and the value of Apartment::Tenant.current which was previously set in a TenantElevator middleware goes back to its default value of "public". This is happening because Devise isn't actally redirecting to the login page but calling the FailureApp (which renders the login page) with a new rack env and returning its

Adding `params` and `session` and `env` to Object

谁都会走 提交于 2019-12-02 04:07:44
In a gem I'm writing I am trying to add the rack methods params , session , and env to Object so that they can be accessed and modified by the user of the gem. I have tried using Object.instance_variable_set and Object.instance_variable_get to add the variables to Object and then set them again by retrieving them from Object . I have been using the Rack::Request.new(env) interface to do this. The only problem is that it seems to be impossible to set params and session through this object. This has led be to believe that I am doing something very wrong. How can I set params and session through

Proc throws error when used with do end [duplicate]

蹲街弑〆低调 提交于 2019-12-02 03:06:09
This question already has an answer here: Code block passed to each works with brackets but not with 'do'-'end' (ruby) 3 answers This doesn't work: run Proc.new do |env| [200, { "Content-Type" => "application/json; charset=UTF-8" }, ["{\"name\":\"Rack App\"}"]] end But this does: run Proc.new { |env| [200, { "Content-Type" => "application/json; charset=UTF-8" }, ["{\"name\":\"Rack App\"}"]] } Any ideas, why its throwing error when used with do..end? Error I am getting: app.ru:1:in new: tried to create Proc object without a block (ArgumentError) Your first code is interpreted as: run(Proc.new)

Apartment current_tenant resets to 'public' after failed devise login

时光总嘲笑我的痴心妄想 提交于 2019-12-02 00:53:50
I use Devise for authentication and Apartment for multi-tenancy support on a SAAS app. After a failed login, devise "redirects" to the login page (Users::SessionsController#new) and the value of Apartment::Tenant.current which was previously set in a TenantElevator middleware goes back to its default value of "public". This is happening because Devise isn't actally redirecting to the login page but calling the FailureApp (which renders the login page) with a new rack env and returning its response. The new rack app doesn't have TenantElevator middleware so the tenant isn't set within the rack

Ruby on rails - rack middleware exclude - is it possible?

核能气质少年 提交于 2019-12-02 00:50:36
I am trying a rack middleware, to do authentication in a separate layer. The problem is, all request goes through this layer. I don't want the asset request like css, javascript to go through authentication middleware., I also don't want logout flow to go through this., In application.rb config.middleware.use AuthClient::MyFilterClass I am expecting something like config.middleware.use AuthClient::MyFilterClass, :exclude => [:logout,'*/assets/*'] Is there any way to exclude custom path / actions from middleware ? Damien MATHIEU Rack middlewares form a up and down stack, like the following

【hadoop】10.HDFS-机架感知

删除回忆录丶 提交于 2019-12-01 12:55:58
简介 通过本教程您可以学习到: 网络拓扑的概念 节点距离的计算 机架感知 如何修改默认的机架设置策略 验证机架感知 1、网络相关知识 1.1、网络拓扑 为了接下来对一些内部机制有所了解,我们先来了解一下网络拓扑的概念。 在本地网络中,两个节点被称为“彼此近邻”是什么意思? 在海量数据处理中,主要限制因素是节点之间数据的传输速率——带宽很稀缺。这里的想法是将两个节点间的带宽作为距离的衡量标准。 我们来了解一个概念:节点距离——两个节点到达最近的共同祖先的距离总和。这个概念,是否也可以理解为拓扑网络中两个节点的最短路径呢(只不过每条边的边长都为1)?(想起了大学时OJ题目中各种最短路径的算法题。) 例如,假设有数据中心d1机架r1中的节点n1。该节点可以表示为/d1/r1/n1。利用这种标记,这里给出四种距离描述。 Distance(/d1/r1/n1, /d1/r1/n1)=0(同一节点上的进程) Distance(/d1/r1/n1, /d1/r1/n2)=2(同一机架上的不同节点) Distance(/d1/r1/n1, /d1/r3/n2)=4(同一数据中心不同机架上的节点) Distance(/d1/r1/n1, /d2/r4/n2)=6(不同数据中心的节点) 1.2、机架感知(副本节点选择) 当我们节点的数目比较多,而副本数比较少的情况下。例如多个DN

Ruby Rack: startup and teardown operations (Tokyo Cabinet connection)

梦想与她 提交于 2019-12-01 08:46:45
I have built a pretty simple REST service in Sinatra, on Rack. It's backed by 3 Tokyo Cabinet/Table datastores, which have connections that need to be opened and closed. I have two model classes written in straight Ruby that currently simply connect, get or put what they need, and then disconnect. Obviously, this isn't going to work long-term. I also have some Rack middleware like Warden that rely on these model classes. What's the best way to manage opening and closing the connections? Rack doesn't provide startup/shutdown hooks as I'm aware. I thought about inserting a piece of middleware