webrick

rails 3.2.3 doesn't work on https using webrick in ubuntu 12.0.4

荒凉一梦 提交于 2019-12-10 13:05:41
问题 Have been trying to get a fresh, just created rails application to work on ssl using webrick in ubuntu 12.0.4. Have tried all possible methods that I'm aware of. Tried using config.force_ssl = true in application.rb , also force_ssl in application controller . For some reasons, when I use https:// loacalhost:3000 on firefox I get an error message saying, ###An error occurred during a connection to localhost:3000.### ###SSL received a record that exceeded the maximum permissible length.### ###

Ruby on Rails: How to start the WEBrick server automatically on Windows in background?

此生再无相见时 提交于 2019-12-10 11:26:05
问题 In order to run the my Rails application on Windows XP I open a command line, cd to application's directory, and then run rails server . I would like to automate this, such that every time I turn on my computer, all I'll have to do is to type localhost:3000 in a browser. How could I do this ? 回答1: The simpler way is to create a batch file with the instruction what you give in the command prompt like d: cd projects\myapp ruby script\server and then drop a copy of the file to Windows Start ->

How can I execute Ruby code with WEBrick instead of dumping the code to my browser?

两盒软妹~` 提交于 2019-12-10 09:41:29
问题 I'm facing a problem when I run my program in a browser with the WEBrick server. It shows me my code as written in the 2loop.rb file. When I run ruby -run -e -httpd. -p 5000 at the command prompt, and load http://localhost:5000/2loop.rb in the browser, it shows the code from 2loop.rb instead of running it. How can I execute the 2loop.rb program instead? 回答1: TL;DR You're doing this to yourself by serving your current working directory as the root of your web server. You aren't actually

For Ruby on Rails, when using Webrick, does it support concurrent requests and Keep-Alive, and why was loading .js and .png files so slow?

为君一笑 提交于 2019-12-09 22:35:17
问题 I am running Rails 3.0.5, and a page is reported on the console that it take 60ms, but if I check the Firefox Net load time chart, it takes 2.9 seconds. If I run the ab command on Bash, it says it take 300ms. So if remove the stand javascripts (6 of them), then it takes 1.9 seconds... but I wonder why so slow? Isn't keep-alive honored? Also strange is Firefox shows that 4 files are downloading concurrently -- I thought Webrick supports only 1 connection as a time? (Will changing to using

How do I cleanly shut down an embedded JRuby in response to a SIGTERM to the JVM process?

痞子三分冷 提交于 2019-12-09 14:06:02
问题 I am running a Middleman (which uses Webrick) server on JRuby inside a JVM process using the org.jruby.embed.ScriptingContainer API. If I shutdown cleanly and stop the server from inside the JVM, everything works as expected. But if I send a SIGTERM to the JVM process (for example, by hitting ctrl+C at the command line), the console returns but the JVM process does not terminate - it hangs around indefinitely until I send it a SIGKILL. I tried registering a JVM shutdown hook to terminate the

How do I attach back to the WEBrick server

拈花ヽ惹草 提交于 2019-12-09 12:11:44
问题 I started the server in detached mode (-d), how do I attach back to it so that I can kill the server). 回答1: Yu can see the id of the ruby process: ps aux | grep ruby username 17731 0.1 1.6 3127008 67996 ?? S 2:00PM 0:01.42 /Users/username/.rvm/rubies/ruby-1.9.2-p180/bin/ruby script/rails s -d and kill process by id: kill -9 17731 回答2: You can use pgrep ruby with kill -9 : kill -9 `pgrep ruby` 回答3: Another way: kill -9 `cat tmp/pids/server.pid` 来源: https://stackoverflow.com/questions/7386093

How to enable SSL for a standalone Sinatra app?

扶醉桌前 提交于 2019-12-09 04:44:24
问题 I want to write a quick server app in Sinatra. It has to be self-contained (i.e. not use apache/nginx/passenger) but also has to support SSL. Is there an easy way to enable SSL support for Sinatra (using WEBRick for example)? 回答1: To do this with MRI ruby, use the following monkeypatch: sinatra_ssl.rb : require 'webrick/https' module Sinatra class Application def self.run! certificate_content = File.open(ssl_certificate).read key_content = File.open(ssl_key).read server_options = { :Host =>

Working around the lack of context in Sinatra's route methods

故事扮演 提交于 2019-12-08 19:42:32
问题 I have been having an issue with missing instances and nilClass errors when calling my routes. After delving around within the source it seems like the generate_method call basically creates a new method using the block of the initial method. get "/" do @some_local_instance.do_something() end So in the above method there could very well be a local variable within that class called some_local_instance, however when the rote is actually evaluated it has no context as to where the method was

Rails 500 server error: undefined method 'formats' for “index”:string

自闭症网瘾萝莉.ら 提交于 2019-12-08 15:58:20
问题 I'm getting a 500 server error in my new rails app. The weird thing is that if you restart the rails server (I'm using the default webrick), the first request after reload is perfectly fine. Every subsequent request, however, returns this 500 error. I wasn't doing anything particularly interesting when it started popping up -- just moving some code around between a helper and model. Any idea where I should start looking to solve this? Here is the text of the error: Started GET "/" for 127.0.0

How to harden rails+webrick+https with insecure ciphers removed on Ruby 2.2

↘锁芯ラ 提交于 2019-12-08 06:30:03
问题 Updated: At first, my test code didn't adequately show ruby 2.4 sees the :SSLCiphers option whereas ruby 2.2 does not. I have edited the example code below to make that clear. Updated: Since my question failed to elicit any help from the community, I forged on ahead and two days later found the solution, which I have included below. I have a small Rails 3 application on Ruby 2.2 and Webrick that handles small loads and therefore does not need the complexity of a "real" web server. It has been