rubber 1.14.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/CHANGELOG +36 -0
  2. data/VERSION +1 -1
  3. data/generators/vulcanize/templates/base/config/rubber/common/crontab +5 -6
  4. data/generators/vulcanize/templates/base/config/rubber/common/rsyslog.conf +71 -0
  5. data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +7 -2
  6. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +4 -12
  7. data/generators/vulcanize/templates/base/script/cron-rake +2 -2
  8. data/generators/vulcanize/templates/complete_passenger_nginx/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  9. data/generators/vulcanize/templates/complete_passenger_nginx/config/rubber/rubber-complete.yml +38 -0
  10. data/generators/vulcanize/templates/complete_passenger_nginx/templates.rb +8 -0
  11. data/generators/vulcanize/templates/complete_passenger_nginx/templates.yml +8 -0
  12. data/generators/vulcanize/templates/complete_passenger_nginx_mysql/templates.yml +4 -0
  13. data/generators/vulcanize/templates/complete_passenger_nginx_postgresql/templates.yml +4 -0
  14. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +1 -1
  15. data/generators/vulcanize/templates/minimal_passenger_nginx/config/rubber/rubber-complete.yml +37 -0
  16. data/generators/vulcanize/templates/minimal_passenger_nginx/templates.yml +4 -0
  17. data/generators/vulcanize/templates/mongodb/config/rubber/deploy-mongodb.rb +6 -2
  18. data/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +1 -0
  19. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +2 -1
  20. data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +0 -0
  21. data/generators/vulcanize/templates/munin/script/munin/example_simple.rb +0 -0
  22. data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +1 -1
  23. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +1 -0
  24. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +1 -1
  25. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +1 -1
  26. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +1 -1
  27. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +1 -1
  28. data/generators/vulcanize/templates/passenger_nginx/config/rubber/deploy-passenger_nginx.rb +86 -0
  29. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/application.conf +30 -0
  30. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/crontab +8 -0
  31. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/monit-nginx.conf +7 -0
  32. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger-memory.conf +34 -0
  33. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger-sudoers.conf +8 -0
  34. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger.conf +47 -0
  35. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx +101 -0
  36. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx.conf +65 -0
  37. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/passenger_nginx.conf +30 -0
  38. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  39. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/tools-index.html +34 -0
  40. data/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  41. data/generators/vulcanize/templates/passenger_nginx/config/rubber/rubber-passenger_nginx.yml +20 -0
  42. data/generators/vulcanize/templates/passenger_nginx/templates.yml +1 -0
  43. data/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +51 -49
  44. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +1 -0
  45. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +20 -7
  46. data/generators/vulcanize/templates/postgresql/config/rubber/role/postgresql_slave/recovery.conf +120 -0
  47. data/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +5 -5
  48. data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +6 -1
  49. data/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +1 -1
  50. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +15 -2
  51. data/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +1 -1
  52. data/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +2 -2
  53. data/lib/generators/vulcanize/templates/base/config/rubber/common/crontab +5 -6
  54. data/lib/generators/vulcanize/templates/base/config/rubber/common/rsyslog.conf +71 -0
  55. data/lib/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +7 -2
  56. data/lib/generators/vulcanize/templates/base/config/rubber/rubber.yml +4 -12
  57. data/lib/generators/vulcanize/templates/base/script/cron-rake +2 -2
  58. data/lib/generators/vulcanize/templates/complete_passenger_nginx/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  59. data/lib/generators/vulcanize/templates/complete_passenger_nginx/config/rubber/rubber-complete.yml +38 -0
  60. data/lib/generators/vulcanize/templates/complete_passenger_nginx/templates.rb +8 -0
  61. data/lib/generators/vulcanize/templates/complete_passenger_nginx/templates.yml +8 -0
  62. data/lib/generators/vulcanize/templates/complete_passenger_nginx_mysql/templates.yml +4 -0
  63. data/lib/generators/vulcanize/templates/complete_passenger_nginx_postgresql/templates.yml +4 -0
  64. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +1 -1
  65. data/lib/generators/vulcanize/templates/minimal_passenger_nginx/config/rubber/rubber-complete.yml +37 -0
  66. data/lib/generators/vulcanize/templates/minimal_passenger_nginx/templates.yml +4 -0
  67. data/lib/generators/vulcanize/templates/mongodb/config/rubber/deploy-mongodb.rb +6 -2
  68. data/lib/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +1 -0
  69. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +2 -1
  70. data/lib/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +0 -0
  71. data/lib/generators/vulcanize/templates/munin/script/munin/example_simple.rb +0 -0
  72. data/lib/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +1 -1
  73. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +1 -0
  74. data/lib/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +1 -1
  75. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +1 -1
  76. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +1 -1
  77. data/lib/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +1 -1
  78. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/deploy-passenger_nginx.rb +86 -0
  79. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/application.conf +30 -0
  80. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/crontab +8 -0
  81. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/monit-nginx.conf +7 -0
  82. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger-memory.conf +34 -0
  83. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger-sudoers.conf +8 -0
  84. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/munin-passenger.conf +47 -0
  85. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx +101 -0
  86. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx.conf +65 -0
  87. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/passenger_nginx/passenger_nginx.conf +30 -0
  88. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  89. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/tools-index.html +34 -0
  90. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  91. data/lib/generators/vulcanize/templates/passenger_nginx/config/rubber/rubber-passenger_nginx.yml +20 -0
  92. data/lib/generators/vulcanize/templates/passenger_nginx/templates.yml +1 -0
  93. data/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +51 -49
  94. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +1 -0
  95. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +20 -7
  96. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/postgresql_slave/recovery.conf +120 -0
  97. data/lib/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +5 -5
  98. data/lib/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +6 -1
  99. data/lib/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +1 -1
  100. data/lib/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +15 -2
  101. data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +1 -1
  102. data/lib/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +2 -2
  103. data/lib/rubber/dns/zerigo.rb +1 -1
  104. data/lib/rubber/recipes/rubber/setup.rb +1 -1
  105. data/lib/rubber/recipes/rubber/volumes.rb +3 -3
  106. metadata +55 -5
@@ -0,0 +1,86 @@
1
+
2
+ namespace :rubber do
3
+
4
+ namespace :passenger_nginx do
5
+
6
+ rubber.allow_optional_tasks(self)
7
+
8
+ after "rubber:install_gems", "rubber:passenger_nginx:custom_install"
9
+
10
+ task :custom_install, :roles => :passenger_nginx do
11
+ rubber.sudo_script 'install_passenger_nginx', <<-ENDSCRIPT
12
+ # Check if there is an nginx with the required version and passenger built in.
13
+ if [ -x /usr/sbin/nginx ]
14
+ then echo 'Found nginx on system'
15
+ pax=$(/usr/sbin/nginx -V 2>&1 | awk '/nginx\\/#{rubber_env.nginx_version}/{a++}/passenger-#{rubber_env.passenger_version}/{b++} END {print a&&b}')
16
+ if [ $pax -eq 1 ]
17
+ then echo 'Nginx/Passenger version matches'
18
+ exit 0
19
+ fi
20
+ fi
21
+ # Lets install
22
+ echo 'Installing / Upgrading nginx #{rubber_env.nginx_version}'
23
+ TMPDIR=`mktemp -d` || exit 1
24
+ cd $TMPDIR
25
+ echo 'Downloading'
26
+ wget -qN http://sysoev.ru/nginx/nginx-#{rubber_env.nginx_version}.tar.gz
27
+ echo 'Unpacking'
28
+ tar xf nginx-#{rubber_env.nginx_version}.tar.gz
29
+ passenger-install-nginx-module --auto --prefix=/opt/nginx --nginx-source-dir=$TMPDIR/nginx-#{rubber_env.nginx_version} --extra-configure-flags="--conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --sbin-path=/usr/sbin/nginx"
30
+ ENDSCRIPT
31
+ end
32
+
33
+ after "rubber:setup_app_permissions", "rubber:passenger_nginx:setup_passenger_permissions"
34
+
35
+ task :setup_passenger_permissions, :roles => :passenger_nginx do
36
+ rsudo "chown #{rubber_env.app_user}:#{rubber_env.app_user} #{current_path}/config/environment.rb"
37
+ end
38
+
39
+ on :load do
40
+ rubber.serial_task self, :serial_restart, :roles => :passenger_nginx do
41
+ rsudo "service nginx restart"
42
+ end
43
+ rubber.serial_task self, :serial_reload, :roles => :passenger_nginx do
44
+ rsudo "if ! ps ax | grep -v grep | grep -c nginx &> /dev/null; then service nginx start; else service nginx reload; fi"
45
+ end
46
+ end
47
+
48
+ before "deploy:stop", "rubber:passenger_nginx:stop"
49
+ after "deploy:start", "rubber:passenger_nginx:start"
50
+ after "deploy:restart", "rubber:passenger_nginx:reload"
51
+
52
+ desc "Stops the nginx web server"
53
+ task :stop, :roles => :passenger_nginx do
54
+ rsudo "service nginx stop; exit 0"
55
+ end
56
+
57
+ desc "Starts the nginx web server"
58
+ task :start, :roles => :passenger_nginx do
59
+ rsudo "service nginx start"
60
+ end
61
+
62
+ desc "Restarts the nginx web server"
63
+ task :restart, :roles => :passenger_nginx do
64
+ serial_restart
65
+ end
66
+
67
+ desc "Reloads the nginx web server"
68
+ task :reload, :roles => :passenger_nginx do
69
+ serial_reload
70
+ end
71
+
72
+
73
+ deploy.task :restart, :roles => :passenger_nginx do
74
+ end
75
+
76
+ deploy.task :reload, :roles => :passenger_nginx do
77
+ end
78
+
79
+ deploy.task :stop, :roles => :passenger_nginx do
80
+ end
81
+
82
+ deploy.task :start, :roles => :passenger_nginx do
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,30 @@
1
+ <%
2
+ @path = "/etc/nginx/rubber/application.conf"
3
+ %>
4
+
5
+ server_name <%= [ rubber_env.domain, rubber_env.web_aliases ].flatten.compact.join(" ") %>;
6
+ passenger_enabled on;
7
+
8
+ passenger_min_instances 1;
9
+
10
+ root <%= RUBBER_ROOT + "/public" %>;
11
+
12
+ # this rewrites all the requests to the maintenance.html
13
+ # page if it exists in the doc root. This is for capistrano's
14
+ # disable web task
15
+ if (-f $document_root/system/maintenance.html)
16
+ {
17
+ rewrite ^(.*)$ /system/maintenance.html last;
18
+ break;
19
+ }
20
+
21
+ error_page 500 502 503 504 /500.html;
22
+ location = /500.html
23
+ {
24
+ root <%= RUBBER_ROOT + "/public" %>;
25
+ }
26
+ error_page 404 /404.html;
27
+ location = /404.html
28
+ {
29
+ root <%= RUBBER_ROOT + "/public" %>;
30
+ }
@@ -0,0 +1,8 @@
1
+ <%
2
+ @read_cmd = 'crontab -l'
3
+ @write_cmd = 'crontab -'
4
+ @additive = ["# rubber-nginx-start", "# rubber-nginx-end"]
5
+ %>
6
+
7
+ # Roll the nginx logs at midnight
8
+ 0 0 * * * LOG_DIR=/mnt/nginx/logs <%= RUBBER_ROOT %>/script/cron-rake rubber:rotate_logs
@@ -0,0 +1,7 @@
1
+ <%
2
+ @path = '/etc/monit/monit.d/monit-nginx.conf'
3
+ %>
4
+ check process nginx with pidfile /var/run/nginx.pid
5
+ group nginx-<%= RUBBER_ENV %>
6
+ start program = "/usr/bin/env service nginx start"
7
+ stop program = "/usr/bin/env service nginx stop"
@@ -0,0 +1,34 @@
1
+ <%
2
+ @path = "/etc/munin/plugins/passenger_memory_status"
3
+ @perms = 0755
4
+ %>#!/usr/bin/env ruby
5
+ # put in /etc/munin/plugins and restart munin-node
6
+ # by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
7
+ # NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats
8
+
9
+ def output_config
10
+ puts <<-END
11
+ graph_category App
12
+ graph_title Passenger memory stats
13
+ graph_vlabel megabytes
14
+
15
+ memory.label memory
16
+ END
17
+ exit 0
18
+ end
19
+
20
+ def output_values
21
+ status = `rvm exec sudo <%= rubber_env.rvm_gem_home %>/bin/passenger-memory-stats | tail -1`
22
+ unless $?.success?
23
+ $stderr.puts "failed executing passenger-memory-stats"
24
+ exit 1
25
+ end
26
+ status =~ /(\d+\.\d+)/
27
+ puts "memory.value #{$1}"
28
+ end
29
+
30
+ if ARGV[0] == "config"
31
+ output_config
32
+ else
33
+ output_values
34
+ end
@@ -0,0 +1,8 @@
1
+ <%
2
+ @path = '/etc/sudoers'
3
+ @additive = ["# munin passenger start", "# munin passenger end"]
4
+ %>
5
+ Defaults env_keep = GEM_PATH
6
+
7
+ nobody ALL=(ALL) NOPASSWD: <%= rubber_env.rvm_gem_home %>/bin/passenger-status
8
+ nobody ALL=(ALL) NOPASSWD: <%= rubber_env.rvm_gem_home %>/bin/passenger-memory-stats
@@ -0,0 +1,47 @@
1
+ <%
2
+ @path = "/etc/munin/plugins/passenger_status"
3
+ @perms = 0755
4
+ %>#!/usr/bin/env ruby
5
+
6
+ # from http://gist.github.com/21328
7
+ # by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
8
+
9
+ def output_config
10
+ puts <<-END
11
+ graph_category App
12
+ graph_title passenger status
13
+ graph_vlabel count
14
+
15
+ sessions.label sessions
16
+ max.label max processes
17
+ running.label running processes
18
+ active.label active processes
19
+ END
20
+ exit 0
21
+ end
22
+
23
+ def output_values
24
+ status = `rvm exec sudo <%= rubber_env.rvm_gem_home %>/bin/passenger-status`
25
+ unless $?.success?
26
+ $stderr.puts "failed executing passenger-status"
27
+ exit 1
28
+ end
29
+ status =~ /max\s+=\s+(\d+)/
30
+ puts "max.value #{$1}"
31
+
32
+ status =~ /count\s+=\s+(\d+)/
33
+ puts "running.value #{$1}"
34
+
35
+ status =~ /active\s+=\s+(\d+)/
36
+ puts "active.value #{$1}"
37
+
38
+ total_sessions = 0
39
+ status.scan(/Sessions: (\d+)/).flatten.each { |count| total_sessions += count.to_i }
40
+ puts "sessions.value #{total_sessions}"
41
+ end
42
+
43
+ if ARGV[0] == "config"
44
+ output_config
45
+ else
46
+ output_values
47
+ end
@@ -0,0 +1,101 @@
1
+ <%
2
+ @path = "/etc/init.d/nginx"
3
+ @perms = 0755
4
+ @post = "/usr/sbin/update-rc.d -f nginx defaults"
5
+ @backup = false
6
+ %>#!/bin/sh
7
+
8
+ ### BEGIN INIT INFO
9
+ # Provides: nginx
10
+ # Required-Start: $local_fs $remote_fs $network $syslog
11
+ # Required-Stop: $local_fs $remote_fs $network $syslog
12
+ # Default-Start: 2 3 4 5
13
+ # Default-Stop: 0 1 6
14
+ # Short-Description: starts the nginx web server
15
+ # Description: starts nginx using start-stop-daemon
16
+ ### END INIT INFO
17
+
18
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
19
+ DAEMON=/usr/sbin/nginx
20
+ NAME=nginx
21
+ DESC=nginx
22
+
23
+ # Include nginx defaults if available
24
+ if [ -f /etc/default/nginx ]; then
25
+ . /etc/default/nginx
26
+ fi
27
+
28
+ test -x $DAEMON || exit 0
29
+
30
+ set -e
31
+
32
+ . /lib/lsb/init-functions
33
+
34
+ test_nginx_config() {
35
+ if $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1; then
36
+ return 0
37
+ else
38
+ $DAEMON -t $DAEMON_OPTS
39
+ return $?
40
+ fi
41
+ }
42
+
43
+ case "$1" in
44
+ start)
45
+ echo -n "Starting $DESC: "
46
+ test_nginx_config
47
+ # Check if the ULIMIT is set in /etc/default/nginx
48
+ if [ -n "$ULIMIT" ]; then
49
+ # Set the ulimits
50
+ ulimit $ULIMIT
51
+ fi
52
+ start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
53
+ --exec $DAEMON -- $DAEMON_OPTS || true
54
+ echo "$NAME."
55
+ ;;
56
+
57
+ stop)
58
+ echo -n "Stopping $DESC: "
59
+ start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
60
+ --exec $DAEMON || true
61
+ echo "$NAME."
62
+ ;;
63
+
64
+ restart|force-reload)
65
+ echo -n "Restarting $DESC: "
66
+ start-stop-daemon --stop --quiet --pidfile \
67
+ /var/run/$NAME.pid --exec $DAEMON || true
68
+ sleep 1
69
+ test_nginx_config
70
+ start-stop-daemon --start --quiet --pidfile \
71
+ /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
72
+ echo "$NAME."
73
+ ;;
74
+
75
+ reload)
76
+ echo -n "Reloading $DESC configuration: "
77
+ test_nginx_config
78
+ start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
79
+ --exec $DAEMON || true
80
+ echo "$NAME."
81
+ ;;
82
+
83
+ configtest|testconfig)
84
+ echo -n "Testing $DESC configuration: "
85
+ if test_nginx_config; then
86
+ echo "$NAME."
87
+ else
88
+ exit $?
89
+ fi
90
+ ;;
91
+
92
+ status)
93
+ status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
94
+ ;;
95
+ *)
96
+ echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2
97
+ exit 1
98
+ ;;
99
+ esac
100
+
101
+ exit 0
@@ -0,0 +1,65 @@
1
+ <%
2
+ @path = "/etc/nginx/nginx.conf"
3
+ @post = "mkdir -p /mnt/nginx/logs"
4
+ %>
5
+
6
+ user <%= rubber_env.app_user %>;
7
+ worker_processes 4;
8
+ worker_rlimit_nofile 10240;
9
+
10
+ pid /var/run/nginx.pid;
11
+
12
+ events
13
+ {
14
+ worker_connections 8192;
15
+ }
16
+
17
+ http
18
+ {
19
+ include /etc/nginx/mime.types;
20
+ default_type application/octet-stream;
21
+
22
+ sendfile on;
23
+ tcp_nopush on;
24
+ tcp_nodelay off;
25
+
26
+ gzip on;
27
+ gzip_http_version 1.0;
28
+ gzip_comp_level 2;
29
+ gzip_proxied any;
30
+
31
+ gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/x-ms-bmp image/svg+xml application/x-font-ttf font/opentype application/vnd.ms-fontobject;
32
+
33
+ # make sure gzip does not lose large gzipped js or css files
34
+ # see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
35
+ gzip_buffers 16 8k;
36
+
37
+ # configure log format like to Apache's "combined" log format
38
+ log_format main
39
+ '$remote_addr - $remote_user [$time_local] '
40
+ '"$request" $status $body_bytes_sent "$http_referer" '
41
+ '"$http_user_agent" "$http_cookie"';
42
+
43
+ # default log files
44
+ error_log /mnt/nginx/logs/error.log notice;
45
+ access_log /mnt/nginx/logs/access.log main;
46
+
47
+ passenger_root <%= rubber_env.passenger_root %>;
48
+ passenger_ruby <%= rubber_env.passenger_ruby %>;
49
+
50
+ passenger_max_pool_size <%= rubber_env.max_app_connections %>;
51
+ passenger_min_instances <%= rubber_env.max_app_connections %>;
52
+ passenger_max_instances_per_app 0;
53
+ passenger_pool_idle_time 0;
54
+ rails_framework_spawner_idle_time 0;
55
+ rails_app_spawner_idle_time 0;
56
+ rails_env <%= RUBBER_ENV %>;
57
+ passenger_friendly_error_pages <%= RUBBER_ENV == 'production' ? 'off' : 'on' %>;
58
+
59
+ passenger_user <%= rubber_env.app_user %>;
60
+
61
+ include /etc/nginx/rubber/passenger_nginx.conf;
62
+ <% if rubber_instances.for_role('web_tools').first %>
63
+ include /etc/nginx/rubber/tools.conf;
64
+ <% end %>
65
+ }
@@ -0,0 +1,30 @@
1
+ <%
2
+ @path = "/etc/nginx/rubber/passenger_nginx.conf"
3
+ %>
4
+
5
+ server {
6
+ ssl on;
7
+ listen <%= rubber_env.passenger_listen_ssl_port %>;
8
+
9
+ proxy_set_header X_FORWARDED_PROTO https;
10
+
11
+
12
+ <% if rubber_env.use_ssl_key %>
13
+ ssl_certificate <%= RUBBER_ROOT %>/config/<%= rubber_env.domain %>.crt;
14
+ ssl_certificate_key <%= RUBBER_ROOT %>/config/<%= rubber_env.domain %>.key;
15
+ <% else %>
16
+ ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
17
+ ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
18
+ <% end %>
19
+
20
+ include /etc/nginx/rubber/application.conf;
21
+ }
22
+
23
+ server {
24
+ listen <%= rubber_env.passenger_listen_port %>;
25
+ include /etc/nginx/rubber/application.conf;
26
+ }
27
+
28
+ passenger_pre_start http://<%= rubber_env.domain %>:<%= rubber_env.passenger_listen_port %>/;
29
+ passenger_pre_start https://<%= rubber_env.domain %>:<%= rubber_env.passenger_listen_ssl_port %>/;
30
+
@@ -0,0 +1,55 @@
1
+ <%
2
+ @path = "/etc/nginx/rubber/tools.conf"
3
+ %>
4
+
5
+
6
+ # This server is setup to serve http.
7
+ server
8
+ {
9
+ listen <%= rubber_env.web_tools_port %>;
10
+ server_name <%= rubber_env.full_host %>;
11
+ root /var/www;
12
+
13
+ rewrite (.*) https://$host:<%= rubber_env.web_tools_ssl_port %>$1 break;
14
+ }
15
+
16
+ # This server is setup to serve https.
17
+ server
18
+ {
19
+ listen <%= rubber_env.web_tools_ssl_port %>;
20
+ server_name <%= rubber_env.full_host %>;
21
+
22
+ ssl on;
23
+ ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
24
+ ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
25
+ # ssl_certificate <%= RUBBER_ROOT %>/config/snapmylife.com.crt;
26
+ # ssl_certificate_key <%= RUBBER_ROOT %>/config/snapmylife.com.key;
27
+
28
+ auth_basic "Rubber Admin Tools";
29
+ auth_basic_user_file <%= RUBBER_ROOT %>/config/<%= rubber_env.app_name %>.auth;
30
+
31
+ client_max_body_size 10M;
32
+ root /var/www;
33
+
34
+
35
+ location /
36
+ {
37
+ # If the file exists as a static file serve it directly without
38
+ # running all the other rewrite tests on it
39
+ if (-f $request_filename)
40
+ {
41
+ break;
42
+ }
43
+
44
+ # check for index.html for directory index
45
+ # if its there on the filesystem then rewite
46
+ # the url to add /index.html to the end of it
47
+ # and then break to send it to the next config rules.
48
+ if (-f $request_filename/index.html)
49
+ {
50
+ rewrite (.*) $1/index.html break;
51
+ }
52
+ }
53
+
54
+ include /etc/nginx/rubber/tools/*.conf;
55
+ }