[ACME] Try to reload services after certificate changes instead of restarting

[DockerAPI] Add service reload commands
This commit is contained in:
andryyy
2018-10-24 20:14:59 +02:00
parent 5f02c6006c
commit 37964d9dd1
2 changed files with 67 additions and 10 deletions

View File

@@ -171,6 +171,41 @@ class container_post(Resource):
except Exception as e:
return jsonify(type='danger', msg=str(e))
elif request.json['cmd'] == 'reload':
if request.json['task'] == 'dovecot':
try:
for container in docker_client.containers.list(filters={"id": container_id}):
# Should be changed to be able to validate a path
reload_return = container.exec_run(["/bin/bash", "-c", "/usr/local/sbin/dovecot reload"])
if reload_return.exit_code == 0:
return jsonify(type='success', msg='command completed successfully')
else:
return jsonify(type='danger', msg='command failed: ' + reload_return.output)
except Exception as e:
return jsonify(type='danger', msg=str(e))
if request.json['task'] == 'postfix':
try:
for container in docker_client.containers.list(filters={"id": container_id}):
# Should be changed to be able to validate a path
reload_return = container.exec_run(["/bin/bash", "-c", "/usr/sbin/postfix reload"])
if reload_return.exit_code == 0:
return jsonify(type='success', msg='command completed successfully')
else:
return jsonify(type='danger', msg='command failed: ' + reload_return.output)
except Exception as e:
return jsonify(type='danger', msg=str(e))
if request.json['task'] == 'nginx':
try:
for container in docker_client.containers.list(filters={"id": container_id}):
# Should be changed to be able to validate a path
reload_return = container.exec_run(["/bin/sh", "-c", "/usr/sbin/nginx -s reload"])
if reload_return.exit_code == 0:
return jsonify(type='success', msg='command completed successfully')
else:
return jsonify(type='danger', msg='command failed: ' + reload_return.output)
except Exception as e:
return jsonify(type='danger', msg=str(e))
elif request.json['cmd'] == 'sieve':
if request.json['task'] == 'list':
if 'username' in request.json: