Merge branch 'dev'

master
André 2017-10-27 11:24:29 +02:00
commit eb6f0ebd81
6 changed files with 89 additions and 46 deletions

View File

@ -1,7 +1,10 @@
from flask import Flask
from flask_restful import Resource, Api
from flask import jsonify
from threading import Thread
import docker
import signal
import time
docker_client = docker.DockerClient(base_url='unix://var/run/docker.sock')
app = Flask(__name__)
@ -54,9 +57,29 @@ class container_post(Resource):
else:
return jsonify(message='Invalid container id or missing action')
class GracefulKiller:
kill_now = False
def __init__(self):
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
def exit_gracefully(self,signum, frame):
self.kill_now = True
def startFlaskAPI():
app.run(debug=False, host='0.0.0.0', port='8080', threaded=True)
api.add_resource(containers_get, '/containers/json')
api.add_resource(container_get, '/containers/<string:container_id>/json')
api.add_resource(container_post, '/containers/<string:container_id>/<string:post_action>')
if __name__ == '__main__':
app.run(debug=False, host='0.0.0.0', port='8080')
api_thread = Thread(target=startFlaskAPI)
api_thread.daemon = True
api_thread.start()
killer = GracefulKiller()
while True:
time.sleep(1)
if killer.kill_now:
break
print "Stopping dockerapi-mailcow"

View File

@ -360,6 +360,22 @@ while true; do
done
) &
# Monitor dockerapi
(
while true; do
while nc -z dockerapi 8080; do
sleep 3
done
echo "Cannot find dockerapi-mailcow, waiting to recover..."
kill -STOP ${BACKGROUND_TASKS[*]}
until nc -z dockerapi 8080; do
sleep 3
done
kill -CONT ${BACKGROUND_TASKS[*]}
kill -USR1 ${BACKGROUND_TASKS[*]}
done
) &
# Restart container when threshold limit reached
while true; do
CONTAINER_ID=

View File

@ -44,11 +44,13 @@ if (isset($_GET['host'])) {
}
} else {
try {
echo '240.240.240.240' . PHP_EOL;
foreach ($redis->hGetAll('WHITELISTED_FWD_HOST') as $host => $source) {
echo $host . "\n";
echo $host . PHP_EOL;
}
}
catch (RedisException $e) {
echo '240.240.240.240' . PHP_EOL;
exit;
}
}

View File

@ -1,7 +1,7 @@
dns {
enable_dnssec = true;
}
map_watch_interval = 15s;
map_watch_interval = 60s;
dns {
timeout = 4s;
retransmits = 5;

View File

@ -17,7 +17,7 @@ rspamd_config:register_symbol({
local tagged_rcpt = task:get_symbol("TAGGED_RCPT")
local mailcow_domain = task:get_symbol("RCPT_MAILCOW_DOMAIN")
if tagged_rcpt and mailcow_domain then
if tagged_rcpt and tagged_rcpt[1].options and mailcow_domain then
local tag = tagged_rcpt[1].options[1]
rspamd_logger.infox("found tag: %s", tag)
local action = task:get_metric_action('default')

View File

@ -215,12 +215,14 @@ services:
depends_on:
- sogo-mailcow
- php-fpm-mailcow
- redis-mailcow
image: nginx:mainline-alpine
command: /bin/sh -c "envsubst < /etc/nginx/conf.d/templates/listen_plain.template > /etc/nginx/conf.d/listen_plain.active &&
envsubst < /etc/nginx/conf.d/templates/listen_ssl.template > /etc/nginx/conf.d/listen_ssl.active &&
envsubst < /etc/nginx/conf.d/templates/server_name.template > /etc/nginx/conf.d/server_name.active &&
nginx -qt &&
until ping phpfpm -c1 > /dev/null; do sleep 1; done &&
until ping redis -c1 > /dev/null; do sleep 1; done &&
exec nginx -g 'daemon off;'"
environment:
- HTTPS_PORT=${HTTPS_PORT:-443}
@ -291,7 +293,7 @@ services:
- /lib/modules:/lib/modules:ro
watchdog-mailcow:
image: mailcow/watchdog:1.8
image: mailcow/watchdog:1.9
build: ./data/Dockerfiles/watchdog
volumes:
- vmail-vol-1:/vmail:ro
@ -310,7 +312,7 @@ services:
- watchdog
dockerapi-mailcow:
image: mailcow/dockerapi:1.0
image: mailcow/dockerapi:1.1
stop_grace_period: 3s
build: ./data/Dockerfiles/dockerapi
volumes: