File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1
1
from fabric .api import *
2
+ import fabric .contrib .files
3
+ import puppet
4
+
5
+ maintenance_config = '/etc/nginx/includes/maintenance.conf'
2
6
3
7
@task
8
+ def enable_maintenance :
9
+ """Enables a maintenance page and serves a 503"""
10
+ """Only to be run on loadbalancers"""
11
+ if not fabric .contrib .files .exists (maintenance_config ):
12
+ abort ("Sorry this task can only currently be run on loadbalancers" )
13
+ puppet .disable ("Maintenance mode enabled" )
14
+ sudo ("echo 'set $maintenance 1;' > {0}" .format (maintenance_config ))
15
+ sudo ('service nginx reload' )
16
+
17
+ def disable_maintenance :
18
+ """Disables a maintenance page"""
19
+ """Only to be run on loadbalancers"""
20
+ if not fabric .contrib .files .exists (maintenance_config ):
21
+ abort ("Sorry this task can only currently be run on loadbalancers" )
22
+ sudo ("echo 'set $maintenance 0;' > {0}" .format (maintenance_config ))
23
+ sudo ('service nginx reload' )
24
+ puppet .enable ()
25
+
4
26
def gracefulstop (wait = True ):
5
27
"""Gracefully shutdown Nginx by finishing any in-flight requests"""
6
28
sudo ('nginx -s quit' )
You can’t perform that action at this time.
0 commit comments