Skip to content

Commit 83fd4bd

Browse files
author
Xiwen Cheng
committed
start.py is our main processs, when it exists stop nginx so that health-check in CF fails correctly
1 parent 5eb7594 commit 83fd4bd

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

start.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import base64
1010
import uuid
11+
import atexit
1112
sys.path.insert(0, 'lib')
1213
import requests
1314
from m2ee import M2EE, logger
@@ -20,13 +21,14 @@
2021

2122
logger.setLevel(buildpackutil.get_buildpack_loglevel())
2223

23-
logger.info('Started Mendix Cloud Foundry Buildpack v1.3.0')
24+
logger.info('Started Mendix Cloud Foundry Buildpack v1.4.0')
2425

2526
logging.getLogger('m2ee').propagate = False
2627

2728

2829
app_is_restarting = False
2930
default_m2ee_password = str(uuid.uuid4()).replace('-', '@') + 'A1'
31+
nginx_process = None
3032

3133

3234
def get_nginx_port():
@@ -114,9 +116,17 @@ def set_up_nginx_files(m2ee):
114116

115117

116118
def start_nginx():
117-
subprocess.Popen([
119+
global nginx_process
120+
nginx_process = subprocess.Popen([
118121
'nginx/sbin/nginx', '-p', 'nginx', '-c', 'conf/nginx.conf'
119122
])
123+
atexit.register(stop_nginx)
124+
125+
126+
def stop_nginx():
127+
if nginx_process:
128+
logger.warning('Stopping nginx')
129+
nginx_process.terminate()
120130

121131

122132
def get_vcap_data():

0 commit comments

Comments
 (0)