wakame 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/History.txt +4 -0
  2. data/LICENSE +202 -0
  3. data/Rakefile +11 -12
  4. data/VERSION +1 -1
  5. data/app_generators/wakame/templates/bin/wakame-agent +1 -1
  6. data/app_generators/wakame/templates/bin/wakame-master +1 -1
  7. data/app_generators/wakame/templates/config/cluster.rb +32 -24
  8. data/app_generators/wakame/templates/config/init.d/centos/wakame-agent +40 -0
  9. data/app_generators/wakame/templates/config/init.d/centos/wakame-master +40 -0
  10. data/app_generators/wakame/templates/config/init.d/wakame-master +1 -1
  11. data/lib/ext/eventmachine.rb +5 -5
  12. data/lib/wakame.rb +12 -0
  13. data/lib/wakame/action.rb +10 -11
  14. data/lib/wakame/actions/deploy_application.rb +61 -0
  15. data/lib/wakame/actions/deploy_config.rb +1 -3
  16. data/lib/wakame/actions/freeze_cluster.rb +15 -0
  17. data/lib/wakame/actions/launch_cluster.rb +1 -3
  18. data/lib/wakame/actions/launch_vm.rb +1 -1
  19. data/lib/wakame/actions/migrate_service.rb +4 -3
  20. data/lib/wakame/actions/notify_child_changed.rb +3 -6
  21. data/lib/wakame/actions/notify_parent_changed.rb +4 -7
  22. data/lib/wakame/actions/propagate_resource.rb +1 -3
  23. data/lib/wakame/actions/propagate_service.rb +1 -3
  24. data/lib/wakame/actions/register_agent.rb +43 -0
  25. data/lib/wakame/actions/reload_service.rb +2 -2
  26. data/lib/wakame/actions/shutdown_cluster.rb +4 -6
  27. data/lib/wakame/actions/shutdown_vm.rb +27 -6
  28. data/lib/wakame/actions/start_service.rb +40 -32
  29. data/lib/wakame/actions/stop_service.rb +8 -10
  30. data/lib/wakame/actions/unfreeze_cluster.rb +15 -0
  31. data/lib/wakame/actor.rb +2 -5
  32. data/lib/wakame/actor/deploy.rb +110 -0
  33. data/lib/wakame/actor/monitor.rb +14 -0
  34. data/lib/wakame/actor/s3fs.rb +45 -0
  35. data/lib/wakame/actor/service_monitor.rb +0 -17
  36. data/lib/wakame/actor/system.rb +5 -1
  37. data/lib/wakame/agent.rb +29 -179
  38. data/lib/wakame/agent_manager.rb +11 -0
  39. data/lib/wakame/agent_managers/actor_manager.rb +101 -0
  40. data/lib/wakame/agent_managers/monitor_manager.rb +48 -0
  41. data/lib/wakame/command.rb +4 -7
  42. data/lib/wakame/command/actor.rb +9 -12
  43. data/lib/wakame/command/agent_status.rb +2 -2
  44. data/lib/wakame/command/control_service.rb +66 -0
  45. data/lib/wakame/command/deploy_application.rb +18 -0
  46. data/lib/wakame/command/deploy_config.rb +16 -0
  47. data/lib/wakame/command/launch_cluster.rb +1 -1
  48. data/lib/wakame/command/launch_vm.rb +1 -1
  49. data/lib/wakame/command/propagate_resource.rb +1 -1
  50. data/lib/wakame/command/propagate_service.rb +5 -3
  51. data/lib/wakame/command/reload_service.rb +1 -1
  52. data/lib/wakame/command/shutdown_cluster.rb +1 -1
  53. data/lib/wakame/command/shutdown_vm.rb +37 -11
  54. data/lib/wakame/command/start_service.rb +1 -1
  55. data/lib/wakame/command/status.rb +6 -4
  56. data/lib/wakame/command/stop_service.rb +1 -1
  57. data/lib/wakame/configuration.rb +5 -0
  58. data/lib/wakame/event.rb +85 -33
  59. data/lib/wakame/event_dispatcher.rb +2 -2
  60. data/lib/wakame/initializer.rb +97 -31
  61. data/lib/wakame/master.rb +23 -346
  62. data/lib/wakame/master_manager.rb +11 -0
  63. data/lib/wakame/master_managers/action_manager.rb +321 -0
  64. data/lib/wakame/master_managers/agent_monitor.rb +166 -0
  65. data/lib/wakame/master_managers/cluster_manager.rb +176 -0
  66. data/lib/wakame/master_managers/command_queue.rb +133 -0
  67. data/lib/wakame/models/agent_pool.rb +113 -0
  68. data/lib/wakame/models/application_repository.rb +34 -0
  69. data/lib/wakame/models/object_store.rb +32 -0
  70. data/lib/wakame/models/service_cluster_pool.rb +36 -0
  71. data/lib/wakame/monitor.rb +3 -6
  72. data/lib/wakame/monitor/agent.rb +9 -6
  73. data/lib/wakame/monitor/service.rb +56 -29
  74. data/lib/wakame/runner/administrator_command.rb +210 -24
  75. data/lib/wakame/runner/agent.rb +2 -0
  76. data/lib/wakame/runner/master.rb +2 -1
  77. data/lib/wakame/service.rb +140 -130
  78. data/lib/wakame/status_db.rb +101 -121
  79. data/lib/wakame/util.rb +26 -15
  80. data/tests/setup_master.rb +1 -0
  81. data/tests/test_master.rb +0 -2
  82. data/tests/test_model_agent_pool.rb +21 -0
  83. data/tests/test_service.rb +14 -8
  84. data/tests/test_status_db.rb +2 -0
  85. data/tests/test_util.rb +12 -1
  86. data/wakame_generators/resource/templates/apache_app/apache_app.rb +20 -11
  87. data/wakame_generators/resource/templates/apache_app/conf/vh/aaa.test.conf +1 -1
  88. data/wakame_generators/resource/templates/apache_lb/apache_lb.rb +7 -7
  89. data/wakame_generators/resource/templates/apache_lb/conf/system-lb.conf +6 -4
  90. data/wakame_generators/resource/templates/apache_www/apache_www.rb +15 -13
  91. data/wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb +17 -17
  92. data/wakame_generators/resource/templates/ec2_elb/ec2_elb.rb +22 -15
  93. data/wakame_generators/resource/templates/mongodb/conf/mongodb.conf +95 -0
  94. data/wakame_generators/resource/templates/mongodb/init.d/mongodb +244 -0
  95. data/wakame_generators/resource/templates/mongodb/mongodb.rb +64 -0
  96. data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +17 -21
  97. data/wakame_generators/resource/templates/nginx/conf/nginx.conf +4 -0
  98. data/wakame_generators/resource/templates/nginx/conf/vh/ec2_elb_common.conf +19 -0
  99. data/wakame_generators/resource/templates/nginx/init.d/nginx +6 -0
  100. data/wakame_generators/resource/templates/nginx/init.d/spawn-fcgi +46 -0
  101. data/wakame_generators/resource/templates/nginx/nginx.rb +15 -10
  102. data/wakame_generators/resource/templates/nginx_passenger/conf/nginx-passenger.conf +39 -0
  103. data/wakame_generators/resource/templates/nginx_passenger/conf/vh/ec2_elb_common.conf +10 -0
  104. data/wakame_generators/resource/templates/nginx_passenger/init.d/nginx-passenger +70 -0
  105. data/wakame_generators/resource/templates/nginx_passenger/nginx_passenger.rb +71 -0
  106. data/wakame_generators/resource/templates/s3fs/s3fs.rb +24 -0
  107. metadata +195 -74
  108. data/lib/wakame/action_manager.rb +0 -303
  109. data/lib/wakame/command/clone_service.rb +0 -12
  110. data/lib/wakame/command_queue.rb +0 -135
  111. data/lib/wakame/vm_manipulator.rb +0 -187
@@ -0,0 +1,244 @@
1
+ #!/bin/sh
2
+ #
3
+ # init.d script with LSB support.
4
+ #
5
+ # Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
6
+ #
7
+ # This is free software; you may redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as
9
+ # published by the Free Software Foundation; either version 2,
10
+ # or (at your option) any later version.
11
+ #
12
+ # This is distributed in the hope that it will be useful, but
13
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License with
18
+ # the Debian operating system, in /usr/share/common-licenses/GPL; if
19
+ # not, write to the Free Software Foundation, Inc., 59 Temple Place,
20
+ # Suite 330, Boston, MA 02111-1307 USA
21
+ #
22
+ ### BEGIN INIT INFO
23
+ # Provides: mongodb
24
+ # Required-Start: $network $local_fs $remote_fs
25
+ # Required-Stop: $network $local_fs $remote_fs
26
+ # Should-Start: $named
27
+ # Should-Stop:
28
+ # Default-Start: 2 3 4 5
29
+ # Default-Stop: 0 1 6
30
+ # Short-Description: An object/document-oriented database
31
+ # Description: MongoDB is a high-performance, open source, schema-free
32
+ # document-oriented data store that's easy to deploy, manage
33
+ # and use. It's network accessible, written in C++ and offers
34
+ # the following features:
35
+ #
36
+ # * Collection oriented storage - easy storage of object-
37
+ # style data
38
+ # * Full index support, including on inner objects
39
+ # * Query profiling
40
+ # * Replication and fail-over support
41
+ # * Efficient storage of binary data including large
42
+ # objects (e.g. videos)
43
+ # * Auto-sharding for cloud-level scalability (Q209)
44
+ #
45
+ # High performance, scalability, and reasonable depth of
46
+ # functionality are the goals for the project.
47
+ ### END INIT INFO
48
+
49
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
50
+ DAEMON=<%= resource.daemon %>
51
+ DAEMON=${DAEMON:-/usr/bin/mongod}
52
+ DESC=database
53
+
54
+ # Default defaults. Can be overridden by the /etc/default/$NAME
55
+ NAME=<%= resource.name %>
56
+ CONF=$WAKAME_ROOT/tmp/config/$NAME/conf/mongodb.conf
57
+ DATA=<%= resource.dbpath %>
58
+ LOGDIR=$(dirname <%= resource.logpath %>)
59
+ PIDFILE=<%= resource.pidpath %>
60
+ LOGFILE=<%= resource.logpath %> # Server logfile
61
+ ENABLE_MONGODB=yes
62
+
63
+ # Include mongodb defaults if available
64
+ if [ -f /etc/default/$NAME ] ; then
65
+ . /etc/default/$NAME
66
+ fi
67
+
68
+ if test ! -x $DAEMON; then
69
+ echo "Could not find $DAEMON"
70
+ exit 0
71
+ fi
72
+
73
+ if test "x$ENABLE_MONGODB" != "xyes"; then
74
+ exit 0
75
+ fi
76
+
77
+ if test ! -x $DATA; then
78
+ mkdir $DATA || exit 0
79
+ fi
80
+
81
+ . /lib/lsb/init-functions
82
+
83
+ STARTTIME=1
84
+ DIETIME=10 # Time to wait for the server to die, in seconds
85
+ # If this value is set too low you might not
86
+ # let some servers to die gracefully and
87
+ # 'restart' will not work
88
+
89
+ DAEMONUSER=${DAEMONUSER:-mongodb}
90
+ DAEMON_OPTS=${DAEMON_OPTS:-"--dbpath $DATA --logpath $LOGFILE run"}
91
+ DAEMON_OPTS="$DAEMON_OPTS --config $CONF"
92
+
93
+ set -e
94
+
95
+
96
+ running_pid() {
97
+ # Check if a given process pid's cmdline matches a given name
98
+ pid=$1
99
+ name=$2
100
+ [ -z "$pid" ] && return 1
101
+ [ ! -d /proc/$pid ] && return 1
102
+ cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
103
+ # Is this the expected server
104
+ [ "$cmd" != "$name" ] && return 1
105
+ return 0
106
+ }
107
+
108
+ running() {
109
+ # Check if the process is running looking at /proc
110
+ # (works for all users)
111
+
112
+ # No pidfile, probably no daemon present
113
+ [ ! -f "$PIDFILE" ] && return 1
114
+ pid=`cat $PIDFILE`
115
+ running_pid $pid $DAEMON || return 1
116
+ return 0
117
+ }
118
+
119
+ start_server() {
120
+ # Start the process using the wrapper
121
+ start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
122
+ --make-pidfile --chuid $DAEMONUSER \
123
+ --exec $DAEMON -- $DAEMON_OPTS
124
+ errcode=$?
125
+ return $errcode
126
+ }
127
+
128
+ stop_server() {
129
+ # Stop the process using the wrapper
130
+ start-stop-daemon --stop --quiet --pidfile $PIDFILE \
131
+ --user $DAEMONUSER \
132
+ --exec $DAEMON
133
+ errcode=$?
134
+ return $errcode
135
+ }
136
+
137
+ force_stop() {
138
+ # Force the process to die killing it manually
139
+ [ ! -e "$PIDFILE" ] && return
140
+ if running ; then
141
+ kill -15 $pid
142
+ # Is it really dead?
143
+ sleep "$DIETIME"s
144
+ if running ; then
145
+ kill -9 $pid
146
+ sleep "$DIETIME"s
147
+ if running ; then
148
+ echo "Cannot kill $NAME (pid=$pid)!"
149
+ exit 1
150
+ fi
151
+ fi
152
+ fi
153
+ rm -f $PIDFILE
154
+ }
155
+
156
+
157
+ case "$1" in
158
+ start)
159
+ log_daemon_msg "Starting $DESC" "$NAME"
160
+ # Check if it's running first
161
+ if running ; then
162
+ log_progress_msg "apparently already running"
163
+ log_end_msg 0
164
+ exit 0
165
+ fi
166
+ if start_server ; then
167
+ # NOTE: Some servers might die some time after they start,
168
+ # this code will detect this issue if STARTTIME is set
169
+ # to a reasonable value
170
+ [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
171
+ if running ; then
172
+ # It's ok, the server started and is running
173
+ log_end_msg 0
174
+ else
175
+ # It is not running after we did start
176
+ log_end_msg 1
177
+ fi
178
+ else
179
+ # Either we could not start it
180
+ log_end_msg 1
181
+ fi
182
+ ;;
183
+ stop)
184
+ log_daemon_msg "Stopping $DESC" "$NAME"
185
+ if running ; then
186
+ # Only stop the server if we see it running
187
+ errcode=0
188
+ stop_server || errcode=$?
189
+ log_end_msg $errcode
190
+ else
191
+ # If it's not running don't do anything
192
+ log_progress_msg "apparently not running"
193
+ log_end_msg 0
194
+ exit 0
195
+ fi
196
+ ;;
197
+ force-stop)
198
+ # First try to stop gracefully the program
199
+ $0 stop
200
+ if running; then
201
+ # If it's still running try to kill it more forcefully
202
+ log_daemon_msg "Stopping (force) $DESC" "$NAME"
203
+ errcode=0
204
+ force_stop || errcode=$?
205
+ log_end_msg $errcode
206
+ fi
207
+ ;;
208
+ restart|force-reload)
209
+ log_daemon_msg "Restarting $DESC" "$NAME"
210
+ errcode=0
211
+ stop_server || errcode=$?
212
+ # Wait some sensible amount, some server need this
213
+ [ -n "$DIETIME" ] && sleep $DIETIME
214
+ start_server || errcode=$?
215
+ [ -n "$STARTTIME" ] && sleep $STARTTIME
216
+ running || errcode=$?
217
+ log_end_msg $errcode
218
+ ;;
219
+ status)
220
+
221
+ log_daemon_msg "Checking status of $DESC" "$NAME"
222
+ if running ; then
223
+ log_progress_msg "running"
224
+ log_end_msg 0
225
+ else
226
+ log_progress_msg "apparently not running"
227
+ log_end_msg 1
228
+ exit 1
229
+ fi
230
+ ;;
231
+ # MongoDB can't reload its configuration.
232
+ reload)
233
+ log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
234
+ log_warning_msg "cannot re-read the config file (use restart)."
235
+ ;;
236
+
237
+ *)
238
+ N=$WAKAME_ROOT/tmp/config/$NAME/init.d/$NAME
239
+ echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
240
+ exit 1
241
+ ;;
242
+ esac
243
+
244
+ exit 0
@@ -0,0 +1,64 @@
1
+ class Mongodb < Wakame::Service::Resource
2
+
3
+ property :name, {:default => "mongodb"}
4
+ property :daemon, {:default => "/usr/sbin/mongod"}
5
+ property :port, {:default => 27017}
6
+ property :dbpath, {:default => "/var/lib/mongodb"}
7
+ property :logpath, {:default => "/var/log/mongodb/mongodb.log"}
8
+ property :pidpath, {:default => "/var/run/mongodb.pid"}
9
+
10
+ update_attribute :monitors, {'/service' => {
11
+ :type => :pidfile,
12
+ :path => "/var/run/mongodb.pid"
13
+ }
14
+ }
15
+
16
+ def render_config(template)
17
+ template.glob_basedir(%w(conf/mongodb.conf init.d/mongodb)) { |d|
18
+ template.render(d)
19
+ }
20
+ #template.cp("init.d/mongodb")
21
+ template.chmod("init.d/mongodb", 0755)
22
+ end
23
+
24
+ def start(svc, action)
25
+ cond = ConditionalWait.new { |cond|
26
+ cond.wait_event(Wakame::Event::ServiceOnline) { |event|
27
+ event.instance_id == svc.id
28
+ }
29
+ }
30
+
31
+ action.actor_request(svc.cloud_host.agent_id,
32
+ '/daemon/start', "mongodb", "init.d/mongodb"){ |req|
33
+ req.wait
34
+ Wakame.log.debug("#{self.class} process started")
35
+ }
36
+
37
+ cond.wait
38
+ end
39
+
40
+ def stop(svc, action)
41
+ cond = ConditionalWait.new { |cond|
42
+ cond.wait_event(Wakame::Event::ServiceOffline) { |event|
43
+ event.instance_id == svc.id
44
+ }
45
+ }
46
+
47
+ action.actor_request(svc.cloud_host.agent_id,
48
+ '/daemon/stop', "mongodb", "init.d/mongodb"){ |req|
49
+ req.wait
50
+ Wakame.log.debug("#{self.class} process stopped")
51
+ }
52
+
53
+ cond.wait
54
+ end
55
+
56
+ def reload(svc, action)
57
+ action.actor_request(svc.cloud_host.agent_id,
58
+ '/daemon/reload', "mongodb", "init.d/mongodb"){ |req|
59
+ req.wait
60
+ Wakame.log.debug("#{self.class} process reloaded")
61
+ }
62
+ end
63
+
64
+ end
@@ -10,12 +10,20 @@ class MySQL_Master < Wakame::Service::Resource
10
10
  property :ebs_device
11
11
  property :ebs_mount_option, {:default=>'noatime'}
12
12
 
13
+ update_attribute :monitors, {
14
+ '/service' => {
15
+ :type=>:command,
16
+ :cmdline=>'/usr/bin/mysqladmin --defaults-file=%{agent.root_path}/tmp/config/mysql_master/conf/my.cnf ping > /dev/null'
17
+ }
18
+ }
19
+
13
20
  def basedir
14
21
  File.join(Wakame.config.root_path, 'cluster', 'resources', 'mysql_master')
15
22
  end
16
23
 
17
24
  def mysqld_datadir
18
- File.expand_path('data', mysqld_basedir)
25
+ #File.expand_path('data', mysqld_basedir)
26
+ File.expand_path(mysqld_basedir)
19
27
  end
20
28
 
21
29
  def mysqld_log_bin
@@ -37,9 +45,9 @@ class MySQL_Master < Wakame::Service::Resource
37
45
 
38
46
  res = ec2.describe_volumes([self.ebs_volume])[0]
39
47
  ec2_instance_id = res[:aws_instance_id]
40
- if res[:aws_status] == 'in-use' && ec2_instance_id == svc.cloud_host.agent.vm_attr[:instance_id]
48
+ if res[:aws_status] == 'in-use' && ec2_instance_id == svc.cloud_host.agent.vm_attr[:aws_instance_id]
41
49
  # Nothin to be done
42
- elsif res[:aws_status] == 'in-use' && ec2_instance_id != svc.cloud_host.agent.vm_attr[:instance_id]
50
+ elsif res[:aws_status] == 'in-use' && ec2_instance_id != svc.cloud_host.agent.vm_attr[:aws_instance_id]
43
51
  ec2.detach_volume(self.ebs_volume)
44
52
  cond = ConditionalWait.new { |c|
45
53
  c.poll {
@@ -49,7 +57,7 @@ class MySQL_Master < Wakame::Service::Resource
49
57
  }
50
58
  cond.wait
51
59
 
52
- ec2.attach_volume(self.ebs_volume, svc.cloud_host.agent.vm_attr[:instance_id], self.ebs_device)
60
+ ec2.attach_volume(self.ebs_volume, svc.cloud_host.agent.vm_attr[:aws_instance_id], self.ebs_device)
53
61
  cond = ConditionalWait.new { |c|
54
62
  c.poll {
55
63
  res1 = ec2.describe_volumes([self.ebs_volume])[0]
@@ -59,7 +67,7 @@ class MySQL_Master < Wakame::Service::Resource
59
67
  cond.wait
60
68
 
61
69
  elsif res[:aws_status] == 'available'
62
- ec2.attach_volume(self.ebs_volume, svc.cloud_host.agent.vm_attr[:instance_id], self.ebs_device)
70
+ ec2.attach_volume(self.ebs_volume, svc.cloud_host.agent.vm_attr[:aws_instance_id], self.ebs_device)
63
71
  cond = ConditionalWait.new { |c|
64
72
  c.poll {
65
73
  res1 = ec2.describe_volumes([self.ebs_volume])[0]
@@ -75,24 +83,17 @@ class MySQL_Master < Wakame::Service::Resource
75
83
  event.instance_id == svc.id
76
84
  }
77
85
  }
78
-
79
- action.actor_request(svc.cloud_host.agent_id,
80
- '/service_monitor/register',
81
- svc.id,
82
- :command, "/usr/bin/mysqladmin --defaults-file=#{svc.cloud_host.agent.root_path}/tmp/config/mysql_master/conf/my.cnf ping > /dev/null") { |req|
83
- }
84
-
86
+
85
87
  action.actor_request(svc.cloud_host.agent_id, '/system/mount', self.ebs_device, self.mysqld_datadir, self.ebs_mount_option) { |req|
86
88
  req.wait
87
89
  Wakame.log.debug("MySQL volume was mounted: #{self.mysqld_datadir}")
88
90
  }
89
-
91
+
90
92
  action.actor_request(svc.cloud_host.agent_id, '/daemon/start', 'mysql_master', 'init.d/mysql') { |req|
91
93
  req.wait
92
94
  Wakame.log.debug("MySQL process started")
93
95
  }
94
-
95
- cond.wait
96
+ cond.wait
96
97
  end
97
98
 
98
99
  def stop(svc, action)
@@ -103,17 +104,12 @@ class MySQL_Master < Wakame::Service::Resource
103
104
  }
104
105
 
105
106
  action.actor_request(svc.cloud_host.agent_id, '/daemon/stop', 'mysql_master', 'init.d/mysql') { |req| req.wait }
107
+ cond.wait
106
108
  action.actor_request(svc.cloud_host.agent_id, '/system/umount', self.mysqld_datadir) { |req|
107
109
  req.wait
108
110
  Wakame.log.debug("MySQL volume unmounted")
109
111
  }
110
112
 
111
- cond.wait
112
-
113
113
  #TODO: Add detach_volume() AWS call here.
114
-
115
- action.actor_request(svc.cloud_host.agent_id,
116
- '/service_monitor/unregister',
117
- svc.id).request
118
114
  end
119
115
  end
@@ -25,6 +25,10 @@ http {
25
25
  proxy_read_timeout 90;
26
26
  proxy_buffers 32 4k;
27
27
 
28
+ # mod_real_ip for ELB
29
+ set_real_ip_from 10.0.0.0/8;
30
+ real_ip_header X-FORWARDED-FOR;
31
+
28
32
  sendfile on;
29
33
  tcp_nopush on;
30
34
 
@@ -0,0 +1,19 @@
1
+ server {
2
+ listen <%= resource.listen_port %>;
3
+ server_name <%= resource.ec2_elb_front_fqdn %>;
4
+ access_log /var/log/nginx/<%= resource.ec2_elb_front_fqdn %>-access.log;
5
+ error_log /var/log/nginx/<%= resource.ec2_elb_front_fqdn %>-error.log;
6
+
7
+ root /var/www;
8
+
9
+ <%- if (resource.fcgi_enabled) %>
10
+ location /
11
+ {
12
+ fastcgi_pass 127.0.0.1:9000;
13
+ fastcgi_read_timeout 5m;
14
+ fastcgi_index index.cgi;
15
+ include /etc/nginx/fastcgi_params;
16
+ }
17
+ <% end %>
18
+
19
+ }
@@ -34,12 +34,18 @@ case "$1" in
34
34
  echo -n "Starting $DESC: "
35
35
  start-stop-daemon --start --oknodo --quiet --pidfile /var/run/$NAME.pid \
36
36
  --exec $DAEMON -- $DAEMON_OPTS
37
+ <%- if (resource.fcgi_enabled) %>
38
+ $WAKAME_ROOT/tmp/config/nginx/init.d/spawn-fcgi start
39
+ <% end %>
37
40
  echo "$NAME."
38
41
  ;;
39
42
  stop)
40
43
  echo -n "Stopping $DESC: "
41
44
  start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid \
42
45
  --exec $DAEMON
46
+ <%- if (resource.fcgi_enabled) %>
47
+ $WAKAME_ROOT/tmp/config/nginx/init.d/spawn-fcgi stop
48
+ <% end %>
43
49
  echo "$NAME."
44
50
  ;;
45
51
  restart|force-reload)