how can i run superset in background #27036
Unanswered
aol-59
asked this question in
Q&A / Help
Replies: 1 comment
-
You can touch a new bash file start.sh , contents: #!/bin/bash
dir_path="/opt/app/superset/logs"
if [ ! -d "$dir_path" ]; then
mkdir -p "$dir_path"
echo "$dir_path has been created"
fi
redis_pid=$(pidof redis-server)
if [ -z "$redis_pid" ]; then
systemctl start redis
echo "Redis has started"
else
echo "Redis is running,PID: $redis_pid"
fi
# shellcheck disable=SC2164
source /opt/app/superset/env/bin/activate
#env_pid=$!
# deactivate
export FLASK_APP=superset
export LD_PRELOAD=/usr/lib64/libstdc++.so.6
export FLASK_ENV=development
current_date=$(date +%Y%m%d)
sh_stop="/opt/app/superset/stop_bi.sh"
echo '#!/bin/bash' > $sh_stop
superset run -p 8001 --with-threads --reload --debugger --host 0.0.0.0 > "/opt/app/superset/logs/${current_date}_superset.log" 2>&1 &
superset_pid=$!
echo "kill ${superset_pid}" >> $sh_stop
echo "superset_pid ${superset_pid}"
celery --app=superset.tasks.celery_app:app worker --pool=prefork -O fair -c 4 --loglevel=info > "/opt/app/superset/logs/${current_date}_worker.log" 2>&1 &
celery_worker_pid=$!
echo "kill ${celery_worker_pid}" >> $sh_stop
echo "celery_worker_pid ${celery_worker_pid}"
celery --app=superset.tasks.celery_app:app beat --loglevel=info > "/opt/app/superset/logs/${current_date}_beat.log" 2>&1 &
celery_beat_pid=$!
echo "kill ${celery_beat_pid}" >> $sh_stop
echo "celery_beat_pid ${celery_beat_pid}"
echo "sleep 3" >> $sh_stop
echo "ps -ef" >> $sh_stop
host_ip=$(hostname -I)
echo "superset client address: ${host_ip// /}:8001"
chmod +x $sh_stop then run The bash contains folder creating, redis starting, celery_worker starting, celery_beat starting. it will genarate log in logs folder and if you want to kill these processers, you can run |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I installed Superset using the following commands:
pip install apache-superset
superset db upgrade
export FLASK_APP=superset
superset fab create-admin
superset load_examples
superset init
superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger
It's working fine, but when I closed the session, Superset shut down. What I want is to run it in the background, so I created a service called superset.service.
i added the variable in /etc/enviroment
nano /etc/systemd/system/superset.service
Then I ran these commands:
systemctl daemon-reload systemctl enable superset systemctl start superset
An internal server error showed up on the page.
[ERROR] Error handling request /login/ Feb 07 13:06:26 Captures-Superset python3[276615]: Traceback (most recent call last): Feb 07 13:06:26 Captures-Superset python3[276615]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 55, in handle Feb 07 13:06:26 Captures-Superset python3[276615]: self.handle_request(listener_name, req, client, addr) Feb 07 13:06:26 Captures-Superset python3[276615]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/ggevent.py", line 128, in handle_request Feb 07 13:06:26 Captures-Superset python3[276615]: super().handle_request(listener_name, req, sock, addr) Feb 07 13:06:26 Captures-Superset python3[276615]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request Feb 07 13:06:26 Captures-Superset python3[276615]: respiter = self.wsgi(environ, resp.start_response) Feb 07 13:06:26 Captures-Superset python3[276615]: File "/home/azureuser/venv/lib/python3.8/site-packages/werkzeug/local.py", line 311, in __get__ Feb 07 13:06:26 Captures-Superset python3[276615]: obj = instance._get_current_object() Feb 07 13:06:26 Captures-Superset python3[276615]: File "/home/azureuser/venv/lib/python3.8/site-packages/werkzeug/local.py", line 508, in _get_current_object Feb 07 13:06:26 Captures-Superset python3[276615]: raise RuntimeError(unbound_message) from None Feb 07 13:06:26 Captures-Superset python3[276615]: RuntimeError: Working outside of application context. Feb 07 13:06:26 Captures-Superset python3[276615]: This typically means that you attempted to use functionality that needed Feb 07 13:06:26 Captures-Superset python3[276615]: the current application. To solve this, set up an application context Feb 07 13:06:26 Captures-Superset python3[276615]: with app.app_context(). See the documentation for more information. Feb 07 13:06:26 Captures-Superset python3[276590]: [2024-02-07 13:06:26 +0000] [276590] [ERROR] Error handling request /login/ Feb 07 13:06:26 Captures-Superset python3[276590]: Traceback (most recent call last): Feb 07 13:06:26 Captures-Superset python3[276590]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 55, in handle Feb 07 13:06:26 Captures-Superset python3[276590]: self.handle_request(listener_name, req, client, addr) Feb 07 13:06:26 Captures-Superset python3[276590]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/ggevent.py", line 128, in handle_request Feb 07 13:06:26 Captures-Superset python3[276590]: super().handle_request(listener_name, req, sock, addr) Feb 07 13:06:26 Captures-Superset python3[276590]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request Feb 07 13:06:26 Captures-Superset python3[276590]: respiter = self.wsgi(environ, resp.start_response) Feb 07 13:06:26 Captures-Superset python3[276590]: File "/home/azureuser/venv/lib/python3.8/site-packages/werkzeug/local.py", line 311, in __get__ Feb 07 13:06:26 Captures-Superset python3[276590]: obj = instance._get_current_object() Feb 07 13:06:26 Captures-Superset python3[276590]: File "/home/azureuser/venv/lib/python3.8/site-packages/werkzeug/local.py", line 508, in _get_current_object Feb 07 13:06:26 Captures-Superset python3[276590]: raise RuntimeError(unbound_message) from None Feb 07 13:06:26 Captures-Superset python3[276590]: RuntimeError: Working outside of application context. Feb 07 13:06:26 Captures-Superset python3[276590]: This typically means that you attempted to use functionality that needed Feb 07 13:06:26 Captures-Superset python3[276590]: the current application. To solve this, set up an application context Feb 07 13:06:26 Captures-Superset python3[276590]: with app.app_context(). See the documentation for more information. Feb 07 13:06:26 Captures-Superset python3[276589]: [2024-02-07 13:06:26 +0000] [276589] [ERROR] Error handling request /favicon.ico Feb 07 13:06:26 Captures-Superset python3[276589]: Traceback (most recent call last): Feb 07 13:06:26 Captures-Superset python3[276589]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 55, in handle Feb 07 13:06:26 Captures-Superset python3[276589]: self.handle_request(listener_name, req, client, addr) Feb 07 13:06:26 Captures-Superset python3[276589]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/ggevent.py", line 128, in handle_request Feb 07 13:06:26 Captures-Superset python3[276589]: super().handle_request(listener_name, req, sock, addr) Feb 07 13:06:26 Captures-Superset python3[276589]: File "/home/azureuser/venv/lib/python3.8/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request Feb 07 13:06:26 Captures-Superset python3[276589]: respiter = self.wsgi(environ, resp.start_response) Feb 07 13:06:26 Captures-Superset python3[276589]: File "/home/azureuser/venv/lib/python3.8/site-packages/werkzeug/local.py", line 311, in __get__ Feb 07 13:06:26 Captures-Superset python3[276589]: obj = instance._get_current_object() Feb 07 13:06:26 Captures-Superset python3[276589]: File "/home/azureuser/venv/lib/python3.8/site-packages/werkzeug/local.py", line 508, in _get_current_object Feb 07 13:06:26 Captures-Superset python3[276589]: raise RuntimeError(unbound_message) from None Feb 07 13:06:26 Captures-Superset python3[276589]: RuntimeError: Working outside of application context. Feb 07 13:06:26 Captures-Superset python3[276589]: This typically means that you attempted to use functionality that needed Feb 07 13:06:26 Captures-Superset python3[276589]: the current application. To solve this, set up an application context Feb 07 13:06:26 Captures-Superset python3[276589]: with app.app_context(). See the documentation for more information.
So, I modified the service by adding these lines:
ExecStart=/home/azureuser/venv/bin/python3 /home/azureuser/venv/bin/gunicorn --workers 8 --worker-class gevent --timeout 120 --limit-request-line 0 --limit-request-field_size 0 --bind 0.0.0.0:8888 --pid /home/azureuser/superset-webserver.PIDFile "superset.app:create_app()"
After reloading and restarting it, it started working. However, when I tried logging in with the username "admin" and password "admin", it showed "Invalid login. Please try again."
can anyone help to resolve this issue or give me another solution?
Beta Was this translation helpful? Give feedback.
All reactions