35 lines
762 B
Python
35 lines
762 B
Python
import json
|
|
import os
|
|
import subprocess
|
|
|
|
config = json.load(open(os.environ['FLEES_CONFIG'],'rt'))
|
|
|
|
TZ = "Etc/UTC"
|
|
if 'timezone' in config:
|
|
TZ = config['timezone']
|
|
assert os.path.exists('/usr/share/zoneinfo/' + TZ), "Invalid timezone '%s'. See /usr/share/zoneinfo/*"%( TZ, )
|
|
|
|
with open('/etc/timezone', 'wt') as fp:
|
|
fp.write(TZ)
|
|
fp.close()
|
|
if os.path.exists('/etc/localtime'):
|
|
os.remove('/etc/localtime')
|
|
os.symlink(
|
|
'/usr/share/zoneinfo/' + TZ,
|
|
'/etc/localtime'
|
|
)
|
|
|
|
env = os.environ.copy()
|
|
env['TZ'] = TZ
|
|
|
|
subprocess.call(
|
|
[
|
|
'gunicorn',
|
|
'-b','0.0.0.0:80',
|
|
'--timeout',str(config['timeout']),
|
|
'-w',str(config['workers']),
|
|
'app:app'
|
|
],
|
|
env = env
|
|
)
|