refined autoremove support

This commit is contained in:
2018-11-18 09:42:41 +02:00
parent 375628255d
commit 9e20d4e115
6 changed files with 55 additions and 27 deletions

View File

@@ -1,5 +1,6 @@
FROM alpine:3.5
RUN apk add --update \
tzdata \
python3 \
python3-dev \
py3-pip \

View File

@@ -14,7 +14,7 @@ from utils.utils import *
from utils.crypt import *
__FLEES_VERSION__ = "20181104.0"
__FLEES_VERSION__ = "20181118.0"
app = Flask(__name__)
app.config.from_object(__name__)
config_values = read_config(app)

View File

@@ -1,11 +1,34 @@
import subprocess,json
import json
import os
import subprocess
config = json.load(open('data/config.json','rt'))
config = json.load(open(os.environ['FLEES_CONFIG'],'rt'))
subprocess.call([
'gunicorn',
'-b','0.0.0.0:80',
'--timeout',str(config['timeout']),
'-w',str(config['workers']),
'app:app'
])
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
)

View File

@@ -1,6 +1,5 @@
import os
from datetime import datetime
from dateutil.relativedelta import relativedelta
from flask import current_app as app
import requests
import re
@@ -122,12 +121,14 @@ def file_age(path):
os.stat(path).st_mtime
)
diff = now - then
rdiff = relativedelta(now, then)
return diff, "%dM %02dD %02d:%02dH" % (
rdiff.years * 12 + rdiff.months,
rdiff.days,
rdiff.hours,
rdiff.minutes
return (
diff,
"%03d d %s"%(
diff.days,
datetime.utcfromtimestamp(
diff.seconds
).strftime('%H:%M:%S')
)
)