htttee 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +1 -2
  2. data/.travis.yml +6 -0
  3. data/README.md +13 -1
  4. data/bin/htttee +2 -2
  5. data/bin/htttee-exec +8 -7
  6. data/config.ru +1 -1
  7. data/htttee.gemspec +4 -3
  8. data/lib/htttee/client.rb +4 -6
  9. data/lib/htttee/client/consumer.rb +38 -34
  10. data/lib/htttee/server.rb +45 -39
  11. data/lib/htttee/server/api.rb +155 -139
  12. data/lib/htttee/server/chunked_body.rb +13 -15
  13. data/lib/htttee/server/middleware/async_fixer.rb +12 -15
  14. data/lib/htttee/server/middleware/dechunker.rb +44 -45
  15. data/lib/htttee/server/middleware/rechunker.rb +15 -0
  16. data/lib/htttee/server/mock.rb +44 -46
  17. data/lib/htttee/server/pubsub_redis.rb +4 -0
  18. data/lib/htttee/server/sse/body.rb +71 -0
  19. data/lib/htttee/server/sse/middleware.rb +96 -0
  20. data/lib/htttee/version.rb +2 -4
  21. data/spec/client_spec.rb +102 -2
  22. data/spec/helpers/rackup.rb +1 -1
  23. data/spec/spec_helper.rb +3 -3
  24. metadata +72 -46
  25. data/deploy/after_restart.rb +0 -1
  26. data/deploy/before_restart.rb +0 -4
  27. data/deploy/before_symlink.rb +0 -2
  28. data/deploy/cookbooks/cloudkick-plugins/recipes/default.rb +0 -8
  29. data/deploy/cookbooks/cloudkick-plugins/recipes/resque.rb +0 -18
  30. data/deploy/cookbooks/cloudkick-plugins/templates/default/resque.sh.erb +0 -4
  31. data/deploy/cookbooks/god/recipes/default.rb +0 -50
  32. data/deploy/cookbooks/god/templates/default/config.erb +0 -3
  33. data/deploy/cookbooks/god/templates/default/god-inittab.erb +0 -3
  34. data/deploy/cookbooks/main/attributes/owner_name.rb +0 -3
  35. data/deploy/cookbooks/main/attributes/recipes.rb +0 -1
  36. data/deploy/cookbooks/main/libraries/dnapi.rb +0 -7
  37. data/deploy/cookbooks/main/recipes/default.rb +0 -2
  38. data/deploy/cookbooks/nginx/files/default/chunkin-nginx-module-v0.22rc1.zip +0 -0
  39. data/deploy/cookbooks/nginx/files/default/nginx-1.0.0.tar.gz +0 -0
  40. data/deploy/cookbooks/nginx/recipes/default.rb +0 -2
  41. data/deploy/cookbooks/nginx/recipes/install.rb +0 -0
  42. data/deploy/cookbooks/nginx/templates/default/nginx.conf.erb +0 -41
  43. data/deploy/cookbooks/resque/recipes/default.rb +0 -47
  44. data/deploy/cookbooks/resque/templates/default/resque.rb.erb +0 -73
  45. data/deploy/cookbooks/resque/templates/default/resque.yml.erb +0 -3
  46. data/deploy/cookbooks/resque/templates/default/resque_scheduler.rb.erb +0 -73
  47. data/deploy/solo.rb +0 -7
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
- export RACK_ENV=<%= @rack_env %>
3
- export REDIS_URI=<%= @redis_uri %>
4
- cd <%= @dir %> && bundle exec <%= @script %>
@@ -1,50 +0,0 @@
1
- execute "restart god" do
2
- command <<-SRC
3
- if pgrep god; then
4
- god quit
5
- fi
6
- SRC
7
- action :nothing
8
- end
9
-
10
- gem_package "god" do
11
- version "0.11.0"
12
- action :install
13
- notifies :run, resources(:execute => "restart god")
14
- end
15
-
16
- directory "/etc/god" do
17
- owner 'root'
18
- group 'root'
19
- mode 0755
20
- recursive true
21
- end
22
-
23
- template "/etc/god/config" do
24
- owner "root"
25
- group "root"
26
- mode 0644
27
- source "config.erb"
28
- end
29
-
30
- execute "telinit q" do
31
- command "telinit q"
32
- action :nothing
33
- end
34
-
35
- template "/tmp/god-inittab" do
36
- owner "root"
37
- group "root"
38
- mode 0644
39
- source "god-inittab.erb"
40
- end
41
-
42
- execute "make init work with god" do
43
- command "cat /tmp/god-inittab >>/etc/inittab"
44
- not_if "grep '# god config' /etc/inittab"
45
- notifies :run, resources(:execute => "telinit q")
46
- end
47
-
48
- file "/tmp/god-inittab" do
49
- action :delete
50
- end
@@ -1,3 +0,0 @@
1
- Dir.glob("/etc/god/*.rb").each do |filename|
2
- load filename
3
- end
@@ -1,3 +0,0 @@
1
- # god config
2
- god:345:respawn:/usr/bin/god -c /etc/god/config -l /var/log/god.log --log-level info -D >> /root/god.log 2>&1
3
- god0:06:wait:/usr/bin/god quit
@@ -1,3 +0,0 @@
1
- # Set the owner_name to the first username
2
- owner_name(@attribute[:users].first[:username])
3
- owner_pass(@attribute[:users].first[:password])
@@ -1 +0,0 @@
1
- recipes "main"
@@ -1,7 +0,0 @@
1
- require "dnapi"
2
-
3
- class Chef::Node
4
- def engineyard
5
- @engineyard ||= DNApi.from(File.read("/etc/chef/dna.json"))
6
- end
7
- end
@@ -1,2 +0,0 @@
1
- require_recipe "resque"
2
- #require_recipe "cloudkick-plugins"
@@ -1,2 +0,0 @@
1
- require_recipe "nginx::install"
2
- require_recipe "nginx::configure"
File without changes
@@ -1,41 +0,0 @@
1
- user ey ey;
2
- worker_processes 4;
3
- pid /var/run/nginx.pid;
4
-
5
- events {
6
- worker_connections 8192;
7
- use epoll;
8
- }
9
-
10
- http {
11
-
12
- upstream thins {
13
- server unix:/tmp/thin.sock;
14
- }
15
-
16
- access_log /var/log/foo.log;
17
- error_log /var/bar.log debug;
18
-
19
- server {
20
- listen 80;
21
- server_name *.amazonaws.com;
22
-
23
- chunkin on;
24
- proxy_buffering off;
25
- chunked_transfer_encoding off;
26
-
27
- location / {
28
- proxy_pass http://thins;
29
- proxy_set_header X-Real-IP $remote_addr;
30
- proxy_buffering off;
31
- #chunked_transfer_encoding on;
32
-
33
- }
34
-
35
- error_page 411 = @my_411_error;
36
- location @my_411_error {
37
- proxy_buffering off;
38
- chunkin_resume;
39
- }
40
- }
41
- }
@@ -1,47 +0,0 @@
1
- if node.engineyard.name == "resque" || node.engineyard.role == "solo"
2
- require_recipe "god"
3
-
4
- node[:applications].each do |app, data|
5
- template "/etc/god/resque_#{app}.rb" do
6
- owner "root"
7
- group "root"
8
- mode 0644
9
- source "resque.rb.erb"
10
- variables(
11
- :app => app,
12
- :app_root => "/data/#{app}/current",
13
- :resque_workers_count => 4
14
- )
15
- notifies :run, resources(:execute => "restart god")
16
- end
17
-
18
- template "/etc/god/resque_scheduler_#{app}.rb" do
19
- owner "root"
20
- group "root"
21
- mode 0644
22
- source "resque_scheduler.rb.erb"
23
- variables(
24
- :app => app,
25
- :app_root => "/data/#{app}/current",
26
- :resque_workers_count => 1
27
- )
28
- notifies :run, resources(:execute => "restart god")
29
- end
30
- end
31
- end
32
-
33
- if %w[solo app app_master util].include? node[:instance_role]
34
- node[:applications].each do |app, data|
35
- template "/data/#{app}/shared/config/resque.yml" do
36
- owner node[:owner_name]
37
- group node[:owner_name]
38
- mode 0655
39
- source "resque.yml.erb"
40
- variables(
41
- :framework_env => node.engineyard.environment.framework_env,
42
- :redis_host => node.engineyard.environment.db_host,
43
- :redis_port => 6379
44
- )
45
- end
46
- end
47
- end
@@ -1,73 +0,0 @@
1
- rack_env = "<%= @node[:environment][:framework_env] %>"
2
- app_name = "<%= @app %>"
3
- app_root = "<%= @app_root %>"
4
- owner = "<%= @node[:owner_name] %>"
5
- home = "/home/#{owner}"
6
- instance_id = "<%= @node.engineyard.id %>"
7
-
8
- <%= @resque_workers_count %>.times do |num|
9
- inline = "#{home}/.ruby_inline/resque-#{app_name}-#{num}"
10
-
11
- God.watch do |w|
12
- w.name = "resque-#{app_name}-#{num}"
13
- w.group = "resque-#{app_name}"
14
- w.uid = owner
15
- w.gid = owner
16
- w.interval = 30.seconds
17
- w.log = "#{app_root}/log/worker.#{num}.log"
18
- w.dir = app_root
19
- w.env = {
20
- "USER" => owner,
21
- "VERBOSE" => "true",
22
- "INSTANCE_ID" => instance_id,
23
- "GOD_WATCH" => w.name,
24
- "RACK_ENV" => rack_env,
25
- "HOME" => home,
26
- "QUEUE" => "*",
27
- }
28
-
29
- w.start = "bundle exec rake --trace init resque:work"
30
-
31
- w.behavior(:clean_pid_file)
32
-
33
- w.start_grace = 2.minutes
34
- w.restart_grace = 2.minutes
35
-
36
- # retart if memory gets too high
37
- w.transition(:up, :restart) do |on|
38
- on.condition(:memory_usage) do |c|
39
- c.above = 350.megabytes
40
- c.times = 2
41
- end
42
- end
43
-
44
- # determine the state on startup
45
- w.transition(:init, { true => :up, false => :start }) do |on|
46
- on.condition(:process_running) do |c|
47
- c.running = true
48
- end
49
- end
50
-
51
- # determine when process has finished starting
52
- w.transition([:start, :restart], :up) do |on|
53
- on.condition(:process_running) do |c|
54
- c.running = true
55
- c.interval = 5.seconds
56
- end
57
-
58
- # failsafe
59
- on.condition(:tries) do |c|
60
- c.times = 5
61
- c.transition = :start
62
- c.interval = 5.seconds
63
- end
64
- end
65
-
66
- # start if process is not running
67
- w.transition(:up, :start) do |on|
68
- on.condition(:process_running) do |c|
69
- c.running = false
70
- end
71
- end
72
- end
73
- end
@@ -1,3 +0,0 @@
1
- <%= @framework_env %>:
2
- redis_host: <%= @redis_host %>
3
- redis_port: <%= @redis_port %>
@@ -1,73 +0,0 @@
1
- rack_env = "<%= @node[:environment][:framework_env] %>"
2
- app_name = "<%= @app %>"
3
- app_root = "<%= @app_root %>"
4
- owner = "<%= @node[:owner_name] %>"
5
- home = "/home/#{owner}"
6
- instance_id = "<%= @node.engineyard.id %>"
7
-
8
- <%= @resque_workers_count %>.times do |num|
9
- inline = "#{home}/.ruby_inline/resque-#{app_name}-#{num}"
10
-
11
- God.watch do |w|
12
- w.name = "resque-scheduler-#{app_name}-#{num}"
13
- w.group = "resque-#{app_name}"
14
- w.uid = owner
15
- w.gid = owner
16
- w.interval = 30.seconds
17
- w.log = "#{app_root}/log/worker-scheduler.#{num}.log"
18
- w.dir = app_root
19
- w.env = {
20
- "USER" => owner,
21
- "VERBOSE" => "true",
22
- "INSTANCE_ID" => instance_id,
23
- "GOD_WATCH" => w.name,
24
- "RACK_ENV" => rack_env,
25
- "HOME" => home,
26
- "QUEUE" => "*",
27
- }
28
-
29
- w.start = "bundle exec rake --trace init resque:scheduler"
30
-
31
- w.behavior(:clean_pid_file)
32
-
33
- w.start_grace = 2.minutes
34
- w.restart_grace = 2.minutes
35
-
36
- # retart if memory gets too high
37
- w.transition(:up, :restart) do |on|
38
- on.condition(:memory_usage) do |c|
39
- c.above = 350.megabytes
40
- c.times = 2
41
- end
42
- end
43
-
44
- # determine the state on startup
45
- w.transition(:init, { true => :up, false => :start }) do |on|
46
- on.condition(:process_running) do |c|
47
- c.running = true
48
- end
49
- end
50
-
51
- # determine when process has finished starting
52
- w.transition([:start, :restart], :up) do |on|
53
- on.condition(:process_running) do |c|
54
- c.running = true
55
- c.interval = 5.seconds
56
- end
57
-
58
- # failsafe
59
- on.condition(:tries) do |c|
60
- c.times = 5
61
- c.transition = :start
62
- c.interval = 5.seconds
63
- end
64
- end
65
-
66
- # start if process is not running
67
- w.transition(:up, :start) do |on|
68
- on.condition(:process_running) do |c|
69
- c.running = false
70
- end
71
- end
72
- end
73
- end
@@ -1,7 +0,0 @@
1
- require 'dnapi'
2
- base_dir = File.dirname(__FILE__)
3
-
4
- file_store_path base_dir
5
- file_cache_path base_dir
6
- cookbook_path "#{base_dir}/cookbooks"
7
- node_name DNApi.from(File.read("/etc/chef/dna.json")).id