winton-cookbook 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,177 @@
1
+ <% if mongrels > 1 %>
2
+ upstream mongrel_<%= application %>_<%= stage %> {
3
+ <% mongrels.times do |x| %>
4
+ server 127.0.0.1:<%= mongrel_port + x %>;
5
+ <% end %>
6
+ }
7
+ <% end %>
8
+
9
+ server {
10
+ listen 80;
11
+
12
+ # Set the max size for file uploads to 50Mb
13
+ client_max_body_size 50M;
14
+
15
+ # sets the domain[s] that this vhost server requests for
16
+ server_name <%= domains.join ' ' %>;
17
+
18
+ # doc root
19
+ root <%= deploy_to %>/current/public;
20
+
21
+ # vhost specific access log
22
+ access_log <%= deploy_to %>/shared/log/nginx.log main;
23
+
24
+ # this rewrites all the requests to the maintenance.html
25
+ # page if it exists in the doc root. This is for capistrano's
26
+ # disable web task
27
+ if (-f $document_root/system/maintenance.html) {
28
+ rewrite ^(.*)$ /system/maintenance.html last;
29
+ break;
30
+ }
31
+
32
+ location / {
33
+ <% if auth_user %>
34
+ auth_basic "Restricted";
35
+ auth_basic_user_file <%= nginx_dir %>/htpasswd/<%= application %>_<%= stage %>;
36
+ <% end %>
37
+
38
+ # needed to forward user's IP address to rails
39
+ proxy_set_header X-Real-IP $remote_addr;
40
+
41
+ # needed for HTTPS
42
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
43
+ proxy_set_header Host $http_host;
44
+ proxy_redirect false;
45
+ proxy_max_temp_file_size 0;
46
+
47
+ # If the file exists as a static file serve it directly without
48
+ # running all the other rewite tests on it
49
+ if (-f $request_filename) {
50
+ break;
51
+ }
52
+
53
+ # check for index.html for directory index
54
+ # if its there on the filesystem then rewite
55
+ # the url to add /index.html to the end of it
56
+ # and then break to send it to the next config rules.
57
+ if (-f $request_filename/index.html) {
58
+ rewrite (.*) $1/index.html break;
59
+ }
60
+
61
+ # this is the meat of the rails page caching config
62
+ # it adds .html to the end of the url and then checks
63
+ # the filesystem for that file. If it exists, then we
64
+ # rewite the url to have explicit .html on the end
65
+ # and then send it on its way to the next config rule.
66
+ # if there is no file on the fs then it sets all the
67
+ # necessary headers and proxies to our upstream mongrels
68
+ if (-f $request_filename.html) {
69
+ rewrite (.*) $1.html break;
70
+ }
71
+
72
+ if (!-f $request_filename) {
73
+ # Use other cluster name here if you are running multiple
74
+ # virtual hosts.
75
+ <% if mongrels == 1 %>
76
+ proxy_pass http://127.0.0.1:<%= mongrel_port %>;
77
+ <% else %>
78
+ proxy_pass http://mongrel_<%= application %>_<%= stage %>;
79
+ <% end %>
80
+ break;
81
+ }
82
+ }
83
+
84
+ error_page 500 502 503 504 /500.html;
85
+ location = /500.html {
86
+ root <%= deploy_to %>/current/public;
87
+ }
88
+ }
89
+
90
+ <% if ssl_cert %>
91
+ server {
92
+ # port to listen on. Can also be set to an IP:PORT
93
+ listen 443;
94
+
95
+ ssl on;
96
+ ssl_certificate <%= deploy_to %>/current/cert/cert;
97
+ ssl_certificate_key <%= deploy_to %>/current/cert/key;
98
+
99
+ # Set the max size for file uploads to 50Mb
100
+ client_max_body_size 50M;
101
+
102
+ # sets the domain[s] that this vhost server requests for
103
+ server_name <%= domains.join ' ' %>;
104
+
105
+ # doc root
106
+ root <%= deploy_to %>/current/public;
107
+
108
+ # vhost specific access log
109
+ access_log <%= deploy_to %>/shared/log/nginx.log main;
110
+
111
+ # this rewrites all the requests to the maintenance.html
112
+ # page if it exists in the doc root. This is for capistrano's
113
+ # disable web task
114
+ if (-f $document_root/system/maintenance.html) {
115
+ rewrite ^(.*)$ /system/maintenance.html last;
116
+ break;
117
+ }
118
+
119
+ location / {
120
+ <% if auth_user %>
121
+ auth_basic "Restricted";
122
+ auth_basic_user_file <%= nginx_dir %>/htpasswd/<%= application %>_<%= stage %>;
123
+ <% end %>
124
+
125
+ # needed to forward user's IP address to rails
126
+ proxy_set_header X-Real-IP $remote_addr;
127
+
128
+ # needed for HTTPS
129
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
130
+ proxy_set_header X-FORWARDED_PROTO https;
131
+ proxy_set_header Host $http_host;
132
+ proxy_redirect false;
133
+ proxy_max_temp_file_size 0;
134
+
135
+ # If the file exists as a static file serve it directly without
136
+ # running all the other rewite tests on it
137
+ if (-f $request_filename) {
138
+ break;
139
+ }
140
+
141
+ # check for index.html for directory index
142
+ # if its there on the filesystem then rewite
143
+ # the url to add /index.html to the end of it
144
+ # and then break to send it to the next config rules.
145
+ if (-f $request_filename/index.html) {
146
+ rewrite (.*) $1/index.html break;
147
+ }
148
+
149
+ # this is the meat of the rails page caching config
150
+ # it adds .html to the end of the url and then checks
151
+ # the filesystem for that file. If it exists, then we
152
+ # rewite the url to have explicit .html on the end
153
+ # and then send it on its way to the next config rule.
154
+ # if there is no file on the fs then it sets all the
155
+ # necessary headers and proxies to our upstream mongrels
156
+ if (-f $request_filename.html) {
157
+ rewrite (.*) $1.html break;
158
+ }
159
+
160
+ if (!-f $request_filename) {
161
+ # Use other cluster name here if you are running multiple
162
+ # virtual hosts.
163
+ <% if mongrels == 1 %>
164
+ proxy_pass http://127.0.0.1:<%= mongrel_port %>;
165
+ <% else %>
166
+ proxy_pass http://mongrel_<%= application %>_<%= stage %>;
167
+ <% end %>
168
+ break;
169
+ }
170
+ }
171
+
172
+ error_page 500 502 503 504 /500.html;
173
+ location = /500.html {
174
+ root <%= deploy_to %>/current/public;
175
+ }
176
+ }
177
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% mongrels.times do |x| %>
2
+ check process mongrel_<%= application %>_<%= mongrel_port + x %> with pidfile <%= deploy_to %>/shared/pids/mongrel.<%= mongrel_port + x %>.pid
3
+ group mongrel
4
+ start program = "mongrel_rails cluster::start -C <%= "#{mongrel_etc_dir}/#{application}_#{stage}.yml" %> --clean --only <%= mongrel_port + x %>"
5
+ stop program = "mongrel_rails cluster::stop -C <%= "#{mongrel_etc_dir}/#{application}_#{stage}.yml" %> --clean --only <%= mongrel_port + x %>"
6
+ if failed host 127.0.0.1 port <%= mongrel_port + x %> protocol http with timeout 10 seconds then restart
7
+ if totalmem is greater than 110.0 MB for 4 cycles then restart # eating up memory?
8
+ if cpu is greater than 50% for 2 cycles then alert # send an email to admin
9
+ if cpu is greater than 80% for 3 cycles then restart # hung process?
10
+ if loadavg(5min) greater than 10 for 8 cycles then restart # bad, bad, bad
11
+ if 20 restarts within 20 cycles then timeout # something is wrong, call the sys-admin
12
+ <% end %>
@@ -0,0 +1,11 @@
1
+ # Defaults for monit initscript
2
+ # sourced by /etc/init.d/monit
3
+ # installed at /etc/default/monit by maintainer scripts
4
+ # Fredrik Steen <stone@debian.org>
5
+
6
+ # You must set this variable to for monit to start
7
+ startup=1
8
+
9
+ # To change the intervals which monit should run uncomment
10
+ # and change this variable.
11
+ # CHECK_INTERVALS=180
@@ -0,0 +1,32 @@
1
+ set daemon 60
2
+ set logfile /var/log/monit.log
3
+ set mailserver localhost
4
+ set mail-format { from: <%= monit_from %> }
5
+ set alert <%= monit_to %>
6
+ set httpd port <%= monit_port %> and allow <%= monit_auth_user %>:<%= monit_auth_pass %>
7
+
8
+ check process sshd with pidfile /var/run/sshd.pid
9
+ start program "/etc/init.d/ssh start"
10
+ stop program "/etc/init.d/ssh stop"
11
+ if failed port <%= ssh_port %> protocol ssh then restart
12
+ if 5 restarts within 5 cycles then timeout
13
+
14
+ check process mysql with pidfile /var/run/mysqld/mysqld.pid
15
+ group database
16
+ start program = "/etc/init.d/mysql start"
17
+ stop program = "/etc/init.d/mysql stop"
18
+ if failed host 127.0.0.1 port 3306 then restart
19
+ if 5 restarts within 5 cycles then timeout
20
+
21
+ check process nginx with pidfile /usr/local/nginx/logs/nginx.pid
22
+ group www
23
+ start program = "/etc/init.d/nginx start"
24
+ stop program = "/etc/init.d/nginx stop"
25
+ if 5 restarts with 5 cycles then timeout
26
+
27
+ check process spawn-fcgi with pidfile /var/run/spawn-fcgi.pid
28
+ group php
29
+ start program = "/etc/init.d/init-fastcgi start"
30
+ stop program = "/etc/init.d/init-fastcgi stop"
31
+ if failed host 127.0.0.1 port 9000 then restart
32
+ if 5 restarts within 5 cycles then timeout
@@ -0,0 +1,26 @@
1
+ upstream monit_httpd {
2
+ server 127.0.0.1:<%= monit_port %>;
3
+ }
4
+
5
+ server {
6
+ listen 80;
7
+
8
+ # sets the domain[s] that this vhost server requests for
9
+ server_name <%= monit_domain %>;
10
+
11
+ # vhost specific access log
12
+ access_log /var/log/monit.nginx.log main;
13
+
14
+ location / {
15
+ # needed to forward user's IP address
16
+ proxy_set_header X-Real-IP $remote_addr;
17
+
18
+ # needed for HTTPS
19
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20
+ proxy_set_header Host $http_host;
21
+ proxy_redirect false;
22
+ proxy_max_temp_file_size 0;
23
+
24
+ proxy_pass http://monit_httpd;
25
+ }
26
+ }
@@ -0,0 +1,137 @@
1
+ #
2
+ # The MySQL database server configuration file.
3
+ #
4
+ # You can copy this to one of:
5
+ # - "/etc/mysql/my.cnf" to set global options,
6
+ # - "~/.my.cnf" to set user-specific options.
7
+ #
8
+ # One can use all long options that the program supports.
9
+ # Run program with --help to get a list of available options and with
10
+ # --print-defaults to see which it would actually understand and use.
11
+ #
12
+ # For explanations see
13
+ # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
14
+
15
+ # This will be passed to all mysql clients
16
+ # It has been reported that passwords should be enclosed with ticks/quotes
17
+ # escpecially if they contain "#" chars...
18
+ # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
19
+ [client]
20
+ port = 3306
21
+ socket = /var/run/mysqld/mysqld.sock
22
+
23
+ # Here is entries for some specific programs
24
+ # The following values assume you have at least 32M ram
25
+
26
+ # This was formally known as [safe_mysqld]. Both versions are currently parsed.
27
+ [mysqld_safe]
28
+ socket = /var/run/mysqld/mysqld.sock
29
+ nice = 0
30
+
31
+ [mysqld]
32
+ #
33
+ # * Basic Settings
34
+ #
35
+ user = mysql
36
+ pid-file = /var/run/mysqld/mysqld.pid
37
+ socket = /var/run/mysqld/mysqld.sock
38
+ port = 3306
39
+ basedir = /usr
40
+ datadir = /var/lib/mysql
41
+ tmpdir = /tmp
42
+ language = /usr/share/mysql/english
43
+ skip-external-locking
44
+ #
45
+ # Instead of skip-networking the default is now to listen only on
46
+ # localhost which is more compatible and is not less secure.
47
+ bind-address = 127.0.0.1
48
+ #
49
+ # * Fine Tuning
50
+ #
51
+ key_buffer = 256M
52
+ max_allowed_packet = 16M
53
+ thread_stack = 128K
54
+ thread_cache_size = 8
55
+ max_connections = 500
56
+ table_cache = 1536
57
+ #thread_concurrency = 10
58
+ #
59
+ # * Query Cache Configuration
60
+ #
61
+ query_cache_limit = 1M
62
+ query_cache_size = 16M
63
+ #
64
+ # * Logging and Replication
65
+ #
66
+ # Both location gets rotated by the cronjob.
67
+ # Be aware that this log type is a performance killer.
68
+ #log = /var/log/mysql/mysql.log
69
+ #
70
+ # Error logging goes to syslog. This is a Debian improvement :)
71
+ #
72
+ # Here you can see queries with especially long duration
73
+ #log_slow_queries = /var/log/mysql/mysql-slow.log
74
+ #long_query_time = 2
75
+ #log-queries-not-using-indexes
76
+ #
77
+ # The following can be used as easy to replay backup logs or for replication.
78
+ #server-id = 1
79
+ log_bin = /var/log/mysql/mysql-bin.log
80
+ # WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!
81
+ expire_logs_days = 10
82
+ max_binlog_size = 100M
83
+ #binlog_do_db = include_database_name
84
+ #binlog_ignore_db = include_database_name
85
+ #
86
+ # * BerkeleyDB
87
+ #
88
+ # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
89
+ skip-bdb
90
+ #
91
+ # * InnoDB
92
+ #
93
+ # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
94
+ # Read the manual for more InnoDB related options. There are many!
95
+ # You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
96
+ skip-innodb
97
+ #
98
+ # * Security Features
99
+ #
100
+ # Read the manual, too, if you want chroot!
101
+ # chroot = /var/lib/mysql/
102
+ #
103
+ # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
104
+ #
105
+ # ssl-ca=/etc/mysql/cacert.pem
106
+ # ssl-cert=/etc/mysql/server-cert.pem
107
+ # ssl-key=/etc/mysql/server-key.pem
108
+
109
+
110
+
111
+ [mysqldump]
112
+ quick
113
+ quote-names
114
+ max_allowed_packet = 16M
115
+
116
+ [mysql]
117
+ #no-auto-rehash # faster start of mysql but no tab completition
118
+
119
+ [isamchk]
120
+ key_buffer = 16M
121
+
122
+ #
123
+ # * NDB Cluster
124
+ #
125
+ # See /usr/share/doc/mysql-server-*/README.Debian for more information.
126
+ #
127
+ # The following configuration is read by the NDB Data Nodes (ndbd processes)
128
+ # not from the NDB Management Nodes (ndb_mgmd processes).
129
+ #
130
+ # [MYSQL_CLUSTER]
131
+ # ndb-connectstring=127.0.0.1
132
+
133
+
134
+ #
135
+ # * IMPORTANT: Additional settings that can override those from this file!
136
+ #
137
+ !includedir /etc/mysql/conf.d/
@@ -0,0 +1,30 @@
1
+ worker_processes 3;
2
+
3
+ events {
4
+ worker_connections 1024;
5
+ }
6
+
7
+ http {
8
+ default_type application/octet-stream;
9
+
10
+ sendfile on;
11
+ tcp_nopush on;
12
+ tcp_nodelay off;
13
+
14
+ keepalive_timeout 65;
15
+
16
+ gzip on;
17
+ gzip_http_version 1.0;
18
+ gzip_comp_level 2;
19
+ gzip_proxied any;
20
+ gzip_types text/plain text/html text/css application/x-javascript text/xml
21
+ application/xml application/xml+rss text/javascript;
22
+
23
+ log_format main '$remote_addr - $remote_user [$time_local] $request '
24
+ '"$status" $body_bytes_sent "$http_referer" '
25
+ '"$http_user_agent" "$http_x_forwarded_for"';
26
+
27
+ include mime.types;
28
+ include fastcgi_params;
29
+ include vhosts/*.conf;
30
+ }
@@ -0,0 +1,57 @@
1
+ #! /bin/sh
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: nginx
5
+ # Required-Start: $all
6
+ # Required-Stop: $all
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: starts the nginx web server
10
+ # Description: starts nginx using start-stop-daemon
11
+ ### END INIT INFO
12
+
13
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
14
+ DAEMON=/usr/local/sbin/nginx
15
+ NAME=nginx
16
+ DESC=nginx
17
+
18
+ test -x $DAEMON || exit 0
19
+ set -e
20
+
21
+ case "$1" in
22
+ start)
23
+ echo -n "Starting $DESC: "
24
+ start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
25
+ --exec $DAEMON -- $DAEMON_OPTS
26
+ echo "$NAME started."
27
+ ;;
28
+ stop)
29
+ echo -n "Stopping $DESC: "
30
+ start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
31
+ --exec $DAEMON
32
+ echo "$NAME stopped."
33
+ ;;
34
+
35
+ restart|force-reload)
36
+ echo -n "Restarting $DESC: "
37
+ start-stop-daemon --stop --quiet --pidfile \
38
+ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON
39
+ sleep 1
40
+ start-stop-daemon --start --quiet --pidfile \
41
+ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
42
+ echo "$NAME restarted."
43
+ ;;
44
+ reload)
45
+ echo -n "Reloading $DESC configuration: "
46
+ start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
47
+ --exec $DAEMON
48
+ echo "$NAME reloaded."
49
+ ;;
50
+ *)
51
+ N=/etc/init.d/$NAME
52
+ echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
53
+ exit 1
54
+ ;;
55
+ esac
56
+
57
+ exit 0
@@ -0,0 +1,26 @@
1
+ #!/bin/bash
2
+
3
+ PHP_SCRIPT=/usr/local/bin/php-fastcgi
4
+ RETVAL=0
5
+
6
+ case "$1" in
7
+ start)
8
+ $PHP_SCRIPT
9
+ RETVAL=$?
10
+ ;;
11
+ stop)
12
+ killall -9 php5-cgi
13
+ RETVAL=$?
14
+ ;;
15
+ restart)
16
+ killall -9 php5-cgi
17
+ $PHP_SCRIPT
18
+ RETVAL=$?
19
+ ;;
20
+ *)
21
+ echo "Usage: php-fastcgi {start|stop|restart}"
22
+ exit 1
23
+ ;;
24
+ esac
25
+
26
+ exit $RETVAL
@@ -0,0 +1,27 @@
1
+ server {
2
+ listen 80;
3
+ server_name <%= domains.join ' ' %>;
4
+
5
+ access_log <%= deploy_to %>/shared/log/nginx.log main;
6
+
7
+ location / {
8
+ root <%= deploy_to %>/current/public;
9
+ index index.html index.htm;
10
+ }
11
+
12
+ # redirect server error pages to the static page /50x.html
13
+
14
+ error_page 500 502 503 504 /50x.html;
15
+ location = /50x.html {
16
+ root <%= deploy_to %>/current/public;
17
+ }
18
+
19
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
20
+
21
+ location ~ \.php$ {
22
+ fastcgi_pass 127.0.0.1:9000;
23
+ fastcgi_index index.php;
24
+ fastcgi_param SCRIPT_FILENAME <%= deploy_to %>/current/public$fastcgi_script_name;
25
+ include fastcgi_params;
26
+ }
27
+ }
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ /usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php5-cgi -P /var/run/spawn-fcgi.pid
@@ -0,0 +1,13 @@
1
+ development: &defaults
2
+ adapter: mysql
3
+ database: <%= db_table %>
4
+ username: <%= db_user %>
5
+ password: <%= db_pass %>
6
+ host: localhost
7
+ socket: /var/run/mysqld/mysqld.sock
8
+
9
+ test:
10
+ <<: *defaults
11
+
12
+ production:
13
+ <<: *defaults
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winton-cookbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh
@@ -23,6 +23,48 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - deploy.rb.example
26
+ - lib/recipes
27
+ - lib/cookbook.rb
28
+ - lib/cookbook_helpers.rb
29
+ - lib/templates
30
+ - lib/recipes/debian.rb
31
+ - lib/recipes/mongrel.rb
32
+ - lib/recipes/deploy.rb
33
+ - lib/recipes/rails.rb
34
+ - lib/recipes/monit.rb
35
+ - lib/recipes/gems.rb
36
+ - lib/recipes/log.rb
37
+ - lib/recipes/php.rb
38
+ - lib/recipes/ssh.rb
39
+ - lib/recipes/stage.rb
40
+ - lib/recipes/nginx.rb
41
+ - lib/recipes/mysql.rb
42
+ - lib/templates/log
43
+ - lib/templates/log/rotate.conf.erb
44
+ - lib/templates/php
45
+ - lib/templates/php/php-fastcgi.erb
46
+ - lib/templates/php/init-fastcgi.erb
47
+ - lib/templates/php/nginx.vhost.erb
48
+ - lib/templates/monit
49
+ - lib/templates/monit/nginx.vhost.erb
50
+ - lib/templates/monit/monitrc.erb
51
+ - lib/templates/monit/mongrel.erb
52
+ - lib/templates/monit/monit.erb
53
+ - lib/templates/nginx
54
+ - lib/templates/nginx/nginx.erb
55
+ - lib/templates/nginx/nginx.conf.erb
56
+ - lib/templates/mysql
57
+ - lib/templates/mysql/my.cnf.erb
58
+ - lib/templates/rails
59
+ - lib/templates/rails/database.yml.erb
60
+ - lib/templates/debian
61
+ - lib/templates/debian/sshd_config.erb
62
+ - lib/templates/debian/iptables.rules.erb
63
+ - lib/templates/debian/bash_profile.erb
64
+ - lib/templates/debian/locale.gen.erb
65
+ - lib/templates/mongrel
66
+ - lib/templates/mongrel/nginx.vhost.erb
67
+ - lib/templates/mongrel/mongrel.yml.erb
26
68
  - MIT-LICENSE
27
69
  - README.markdown
28
70
  has_rdoc: false