Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

-Added cookbook for configuring unicorn+nginx

  • Loading branch information...
commit 5b609e65a8101eada653770a4590f09dddfdbc9b 1 parent 70341ca
@sergio1990 sergio1990 authored
View
1  basic_setup/nodes/vagrant.json
@@ -36,5 +36,6 @@
"recipe[postgresql::server]",
"recipe[postgresql::ruby]",
"recipe[git]",
+ "recipe[unicorn]"
]
}
View
13 basic_setup/site-cookbooks/unicorn/CHANGELOG.md
@@ -0,0 +1,13 @@
+unicorn CHANGELOG
+=================
+
+This file is used to list changes made in each version of the unicorn cookbook.
+
+0.1.0
+-----
+- [your_name] - Initial release of unicorn
+
+- - -
+Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
+
+The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.
View
68 basic_setup/site-cookbooks/unicorn/README.md
@@ -0,0 +1,68 @@
+unicorn Cookbook
+================
+TODO: Enter the cookbook description here.
+
+e.g.
+This cookbook makes your favorite breakfast sandwich.
+
+Requirements
+------------
+TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
+
+e.g.
+#### packages
+- `toaster` - unicorn needs toaster to brown your bagel.
+
+Attributes
+----------
+TODO: List your cookbook attributes here.
+
+e.g.
+#### unicorn::default
+<table>
+ <tr>
+ <th>Key</th>
+ <th>Type</th>
+ <th>Description</th>
+ <th>Default</th>
+ </tr>
+ <tr>
+ <td><tt>['unicorn']['bacon']</tt></td>
+ <td>Boolean</td>
+ <td>whether to include bacon</td>
+ <td><tt>true</tt></td>
+ </tr>
+</table>
+
+Usage
+-----
+#### unicorn::default
+TODO: Write usage instructions for each cookbook.
+
+e.g.
+Just include `unicorn` in your node's `run_list`:
+
+```json
+{
+ "name":"my_node",
+ "run_list": [
+ "recipe[unicorn]"
+ ]
+}
+```
+
+Contributing
+------------
+TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
+
+e.g.
+1. Fork the repository on Github
+2. Create a named feature branch (like `add_component_x`)
+3. Write your change
+4. Write tests for your change (if applicable)
+5. Run the tests, ensuring they all pass
+6. Submit a Pull Request using Github
+
+License and Authors
+-------------------
+Authors: TODO: List authors
View
6 basic_setup/site-cookbooks/unicorn/attributes/default.rb
@@ -0,0 +1,6 @@
+default['unicorn']['app_name'] = "sample"
+default['unicorn']['rails_root'] = "/var/www/#{node.unicorn.app_name}"
+default['unicorn']['server_name'] = "localhost"
+default['unicorn']['sock_path'] = "shared/unicorn.sock"
+default['unicorn']['enabled'] = true
+default['unicorn']['nginx_root'] = "/etc/nginx"
View
7 basic_setup/site-cookbooks/unicorn/metadata.rb
@@ -0,0 +1,7 @@
+name 'unicorn'
+maintainer 'AlterEGO Labs'
+maintainer_email 'sergeg1990@gmail.com'
+license 'Apache 2.0'
+description 'Installs/Configures unicorn'
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version '0.1.0'
View
35 basic_setup/site-cookbooks/unicorn/recipes/default.rb
@@ -0,0 +1,35 @@
+#
+# Cookbook Name:: unicorn
+# Recipe:: default
+#
+# Copyright 2014, AlterEGO Labs
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+file_config = "#{node.unicorn.nginx_root}/sites-available/#{node.unicorn.app_name}"
+enable_file_config = "#{node.unicorn.nginx_root}/sites-enabled/#{node.unicorn.app_name}"
+
+template file_config do
+ source 'unicorn_site_config.erb'
+ mode '0644'
+end
+
+link enable_file_config do
+ to file_config
+ only_if { node.unicorn.enabled }
+end
+
+service "nginx" do
+ action :restart
+end
View
41 basic_setup/site-cookbooks/unicorn/templates/default/unicorn_site_config.erb
@@ -0,0 +1,41 @@
+upstream <%= node.unicorn.app_name %>_server{
+ server unix:<%= node.unicorn.rails_root %>/<%= node.unicorn.sock_path %> fail_timeout=0;
+}
+
+server {
+ listen 80;
+ server_name <%= node.unicorn.server_name %>;
+ client_max_body_size 1G;
+ root <%= node.unicorn.rails_root %>/current/public;
+ keepalive_timeout 5;
+
+ try_files $uri/index.html $uri.html $uri @<%= node.unicorn.app_name %>app;
+
+ location @<%= node.unicorn.app_name %>app{
+ proxy_pass http://<%= node.unicorn.app_name %>_server;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_redirect off;
+ }
+
+ if (-f $document_root/maintenance.html) {
+ return 503;
+ }
+
+ error_page 404 /404.html;
+ error_page 500 502 504 /500.html;
+ error_page 503 @503;
+
+ location @503 {
+ rewrite ^(.*)$ /maintenance.html break;
+ }
+
+ location ~ ^/assets/ {
+ gzip_static on;
+ expires max;
+ add_header Cache-Control public;
+ add_header ETag "";
+ break;
+ }
+
+}

0 comments on commit 5b609e6

Please sign in to comment.
Something went wrong with that request. Please try again.