From 0f395eae21f25b130600f45ab9cbde724c6677f6 Mon Sep 17 00:00:00 2001 From: kev Date: Thu, 17 Oct 2019 23:59:58 +0800 Subject: [PATCH] add systemd files for airflow+superset --- airflow/systemd/airflow | 24 +++++++++++++++++++++ airflow/systemd/airflow-flower.service | 16 ++++++++++++++ airflow/systemd/airflow-scheduler.service | 16 ++++++++++++++ airflow/systemd/airflow-webserver.service | 18 ++++++++++++++++ airflow/systemd/airflow-worker.service | 16 ++++++++++++++ superset/systemd/superset | 4 ++++ superset/systemd/superset-flower.service | 16 ++++++++++++++ superset/systemd/superset-webserver.service | 16 ++++++++++++++ superset/systemd/superset-worker.service | 16 ++++++++++++++ 9 files changed, 142 insertions(+) create mode 100644 airflow/systemd/airflow create mode 100644 airflow/systemd/airflow-flower.service create mode 100644 airflow/systemd/airflow-scheduler.service create mode 100644 airflow/systemd/airflow-webserver.service create mode 100644 airflow/systemd/airflow-worker.service create mode 100644 superset/systemd/superset create mode 100644 superset/systemd/superset-flower.service create mode 100644 superset/systemd/superset-webserver.service create mode 100644 superset/systemd/superset-worker.service diff --git a/airflow/systemd/airflow b/airflow/systemd/airflow new file mode 100644 index 0000000..eea7a66 --- /dev/null +++ b/airflow/systemd/airflow @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# This file is the environment file for Airflow. Put this file in /etc/sysconfig/airflow per default +# configuration of the systemd unit files. +# +AIRFLOW_HOME=/home/airflow/airflow +AIRFLOW_CONFIG=/home/airflow/airflow/airflow.cfg +PATH=/home/airflow/.virtualenvs/airflow/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games diff --git a/airflow/systemd/airflow-flower.service b/airflow/systemd/airflow-flower.service new file mode 100644 index 0000000..e8bab93 --- /dev/null +++ b/airflow/systemd/airflow-flower.service @@ -0,0 +1,16 @@ +[Unit] +Description=Airflow celery flower +After=network.target postgresql.service redis-server.service +Wants=postgresql.service redis-server.service + +[Service] +EnvironmentFile=/etc/default/airflow +User=airflow +Group=airflow +Type=simple +ExecStart=/home/airflow/.virtualenvs/airflow/bin/airflow flower --port=5555 +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/airflow/systemd/airflow-scheduler.service b/airflow/systemd/airflow-scheduler.service new file mode 100644 index 0000000..e17667f --- /dev/null +++ b/airflow/systemd/airflow-scheduler.service @@ -0,0 +1,16 @@ +[Unit] +Description=Airflow scheduler daemon +After=network.target postgresql.service redis-server.service +Wants=postgresql.service redis-server.service + +[Service] +EnvironmentFile=/etc/default/airflow +User=airflow +Group=airflow +Type=simple +ExecStart=/home/airflow/.virtualenvs/airflow/bin/airflow scheduler +Restart=always +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/airflow/systemd/airflow-webserver.service b/airflow/systemd/airflow-webserver.service new file mode 100644 index 0000000..24e76c1 --- /dev/null +++ b/airflow/systemd/airflow-webserver.service @@ -0,0 +1,18 @@ +[Unit] +Description=Airflow webserver daemon +After=network.target postgresql.service redis-server.service +Wants=postgresql.service redis-server.service + +[Service] +EnvironmentFile=/etc/default/airflow +User=airflow +Group=airflow +Type=simple +RuntimeDirectory=airflow +ExecStart=/home/airflow/.virtualenvs/airflow/bin/airflow webserver --pid /run/airflow/webserver.pid +Restart=on-failure +RestartSec=5s +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/airflow/systemd/airflow-worker.service b/airflow/systemd/airflow-worker.service new file mode 100644 index 0000000..b961910 --- /dev/null +++ b/airflow/systemd/airflow-worker.service @@ -0,0 +1,16 @@ +[Unit] +Description=Airflow celery worker daemon +After=network.target postgresql.service redis-server.service +Wants=postgresql.service redis-server.service + +[Service] +EnvironmentFile=/etc/default/airflow +User=airflow +Group=airflow +Type=simple +ExecStart=/home/airflow/.virtualenvs/airflow/bin/airflow worker +Restart=on-failure +RestartSec=10s + +[Install] +WantedBy=multi-user.target diff --git a/superset/systemd/superset b/superset/systemd/superset new file mode 100644 index 0000000..e57cd3b --- /dev/null +++ b/superset/systemd/superset @@ -0,0 +1,4 @@ +PYTHONPATH=/home/superset/superset +SUPERSET_HOME=/home/superset/superset +FLASK_APP=superset +GUNICORN_CMD_ARGS="--workers=4 --timeout=60 --bind=0.0.0.0:8088 --limit-request-line=0 --limit-request-field_size=0" diff --git a/superset/systemd/superset-flower.service b/superset/systemd/superset-flower.service new file mode 100644 index 0000000..d7fc05e --- /dev/null +++ b/superset/systemd/superset-flower.service @@ -0,0 +1,16 @@ +[Unit] +Description=Superset celery flower +After=network.target postgresql.service redis-server.service +Wants=postgresql.service redis-server.service + +[Service] +EnvironmentFile=/etc/default/superset +User=superset +Group=superset +Type=simple +ExecStart=/home/superset/.virtualenvs/superset/bin/celery flower --app=superset.tasks.celery_app:app --port=5555 +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/superset/systemd/superset-webserver.service b/superset/systemd/superset-webserver.service new file mode 100644 index 0000000..d9482dc --- /dev/null +++ b/superset/systemd/superset-webserver.service @@ -0,0 +1,16 @@ +[Unit] +Description=Superset webserver daemon +After=network.target postgresql.service redis-server.service +Wants=postgresql.service redis-server.service + +[Service] +EnvironmentFile=/etc/default/superset +User=superset +Group=superset +Type=simple +ExecStart=/home/superset/.virtualenvs/superset/bin/gunicorn superset:app +Restart=on-failure +RestartSec=5s + +[Install] +WantedBy=multi-user.target diff --git a/superset/systemd/superset-worker.service b/superset/systemd/superset-worker.service new file mode 100644 index 0000000..b178146 --- /dev/null +++ b/superset/systemd/superset-worker.service @@ -0,0 +1,16 @@ +[Unit] +Description=Superset celery worker daemon +After=network.target postgresql.service redis-server.service +Wants=postgresql.service redis-server.service + +[Service] +EnvironmentFile=/etc/default/superset +User=superset +Group=superset +Type=simple +ExecStart=/home/superset/.virtualenvs/superset/bin/celery worker --app=superset.tasks.celery_app:app --pool=prefork -Ofair -c 4 +Restart=on-failure +RestartSec=10s + +[Install] +WantedBy=multi-user.target