Last active
June 30, 2024 17:02
-
-
Save ryanbekhen/92a0649d28c23de4718848814e4ffa4f to your computer and use it in GitHub Desktop.
Instant Installation Apache Superset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SUPERSET_DIR=~/superset | |
sudo apt-get update -y # update package | |
sudo apt-get install build-essential libssl-dev libffi-dev python-pip libsasl2-dev libldap2-dev default-libmysqlclient-dev -y # install package | |
sudo apt-get install python3-pip python3.10-venv -y # install package | |
[ ! -d $SUPERSET_DIR ] && mkdir $SUPERSET_DIR | |
python3 -m venv $SUPERSET_DIR/venv # buat vertual env | |
. $SUPERSET_DIR/venv/bin/activate # jalankan vertual env | |
pip install wheel # install wheel | |
pip install --upgrade pip setuptools wheel # upgrade pip setuptools wheel | |
pip install apache-superset pymysql # install superset | |
# configuration | |
SECRET_KEY=$(openssl rand -base64 42) | |
cat > $SUPERSET_DIR/superset_config.py <<EOF | |
ROW_LIMIT = 5000 | |
SECRET_KEY = '$SECRET_KEY' | |
SQLALCHEMY_DATABASE_URI = 'sqlite:////$SUPERSET_DIR/superset.db?check_same_thread=false' | |
TALISMAN_ENABLED = False | |
WTF_CSRF_ENABLED = False | |
WTF_CSRF_EXEMPT_LIST = [] | |
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365 | |
MAPBOX_API_KEY = '' | |
EOF | |
export FLASK_APP=superset | |
export SUPERSET_CONFIG_PATH=$SUPERSET_DIR/superset_config.py | |
superset db upgrade # init db | |
superset fab create-admin # create admin | |
superset load_examples # load data sample | |
superset init # init role dan permission | |
# create systemd service | |
CURRENT_USER=$(whoami) | |
sudo touch /etc/systemd/system/superset.service | |
sudo chown $CURRENT_USER:$CURRENT_USER /etc/systemd/system/superset.service | |
cat > /etc/systemd/system/superset.service <<EOF | |
[Unit] | |
Description=Superset daemon | |
After=network.target | |
[Service] | |
User=$CURRENT_USER | |
Environment="PATH=$SUPERSET_DIR/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | |
Environment="FLASK_APP=superset" | |
Environment="SUPERSET_CONFIG_PATH=$SUPERSET_DIR/superset_config.py" | |
# Execute virtualenv activate script to set environment variables and then start the daemon directly in 0.0.0.0:8088 (i.e. not via supersets) | |
ExecStart=$SUPERSET_DIR/venv/bin/python $SUPERSET_DIR/venv/bin/superset run -p 8088 -h 0.0.0.0 --with-threads --reload --debugger | |
WorkingDirectory=$SUPERSET_DIR | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
sudo chown root:root /etc/systemd/system/superset.service | |
sudo systemctl daemon-reload | |
sudo systemctl enable superset | |
sudo systemctl start superset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment