superset icon indicating copy to clipboard operation
superset copied to clipboard

How to daemonize superset process

Open zhangjiajie023 opened this issue 9 years ago • 20 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if any
  • [x] I have reproduced the issue with at least the latest released version of superset
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.15.0

Expected results

Detaches the server from the controlling terminal and enters the background

Actual results

can't realize running superset at backend

Steps to reproduce

gunicorn is superset's server, I add the parameter -D --daemon in bin.superset.run_server(), but don't work. Is there any other way s to detaches the server from the controlling terminal and enters the background?

zhangjiajie023 avatar Feb 07 '17 02:02 zhangjiajie023

I found that I can close the controlling terminal and the gunicorn still run as a daemon. But there is no order to stop/restart superset, have to kill the superset process, right? Or exist other ways?

zhangjiajie023 avatar Feb 07 '17 04:02 zhangjiajie023

What about letting your init system take care of superset?

xrmx avatar Feb 07 '17 08:02 xrmx

I've written a simple systemd service:

[Unit]
Description=Visualization platform by Airbnb

[Service]
Type=simple
ExecStart=/usr/local/bin/superset runserver -p 8088 -t 300

petroswork avatar Feb 09 '17 09:02 petroswork

@petroswork 👍

xrmx avatar Feb 09 '17 11:02 xrmx

@petroswork nice

zhangjiajie023 avatar Mar 06 '17 04:03 zhangjiajie023

Thanks for this. I had to make the following change on Azure:

[Service]
Type=simple
User=username
ExecStart=/usr/local/bin/superset runserver -p 8088 -t 300

nobodhi avatar May 29 '17 14:05 nobodhi

@josebrwn Mine was meant as a user service, i.e. appears in systemctl --user.

petroswork avatar May 30 '17 07:05 petroswork

With few improvements works well for me.

#superset.service ########### [Unit] Description=Visualization platform by Airbnb After=multi-user.target

[Service] Type=simple User=USER ExecStart=/opt/superset/venv/bin/superset runserver

[Install] WantedBy=default.target

fuzaro avatar May 30 '17 19:05 fuzaro

For the record we use chef/runit at Airbnb. Hopefully we get to ship with some Linux distros that will take care of that eventualy :)

mistercrunch avatar May 31 '17 16:05 mistercrunch

Hi running the script from @fuzaro I'm getting /bin/sh: 1: gunicorn: not found message, that's due to the virtualenv is not active, I guess.. Any clue on how to solve? Thanks

pastarace avatar Feb 12 '18 11:02 pastarace

@pastarace change /var/superset/superset/ with path to your Virtualenv. It's working I checked. You can also remove PYTHONPATH line. I added it because I am using local configuration file.

[Unit]
Description=Superset service 
After=network.target

[Service]
Type=simple
User=superset 
Group=superset 
Environment=PATH=/var/superset/superset/bin:$PATH
Environment=PYTHONPATH=/var/superset/superset:$PYTHONPATH
ExecStart=/var/superset/superset/bin/superset runserver

[Install]
WantedBy=multi-user.target

liptanbiswas avatar Feb 19 '18 13:02 liptanbiswas

Would recommend using a straight gunicorn in place of superset runserver to allow for more control and avoid an extra level of shelling

mistercrunch avatar Feb 19 '18 17:02 mistercrunch

@liptanbiswas can I use my own configuration file as well? Does this work?? please assist like this: [unit] Description=SUPERSET systemd service script After=network.target

[Service] Type=simple User=root Environment=PATH=/opt/venv/bin:$PATH Environment=PYTHONPATH=/opt/superset/superset_config.py:$PYTHONPATH ExecStart=/opt/venv/bin/superset runserver Restart=always

[Install] WantedBy=multi-user.target

nagaraju02 avatar Sep 26 '18 19:09 nagaraju02

@nagaraju02 Yes you can. You see in the script I pasted above, I am putting superset_config.py in /var/superset/superset dir. You don't need to put the whole path.

Environment=PYTHONPATH=/opt/superset:$PYTHONPATH will do fine.

However, since you have installed the application in /opt/venv, I would recommend you to put the superset_config.py in this dir and make it Environment=PYTHONPATH=/opt/venv:$PYTHONPATH.

liptanbiswas avatar Sep 27 '18 19:09 liptanbiswas

@liptanbiswas thanks a lot! I will give a try.

Thanks It worked!

nagaraju02 avatar Sep 28 '18 21:09 nagaraju02

Make sure these boxes are checked before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if any
  • [x] I have reproduced the issue with at least the latest released version of superset
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.15.0

Expected results

Detaches the server from the controlling terminal and enters the background

Actual results

can't realize running superset at backend

Steps to reproduce

gunicorn is superset's server, I add the parameter -D --daemon in bin.superset.run_server(), but don't work. Is there any other way s to detaches the server from the controlling terminal and enters the background?

Use the comando nohup before the command and put & in the final

example: nohup superset runserver -p 8088 &

jonathangueedes avatar Jul 15 '19 22:07 jonathangueedes

I've written a simple systemd service:

[Unit]
Description=Visualization platform by Airbnb

[Service]
Type=simple
ExecStart=/usr/local/bin/superset runserver -p 8088 -t 300

where to add this file and what is the case of the virtual environment?? any help is appreciated asap

Aabhusan avatar Dec 06 '19 10:12 Aabhusan

Can any one help me out what what in case supercet Is running on python virtual environment?

how we can get into python virtual environment and how we can setup this process

GOPIPACHA avatar Jul 01 '20 10:07 GOPIPACHA

@GOPIPACHA The python environment can be specified in the .service file as "Environment=PYTHONPATH=/home/rspl_test/venv_s/bin:$PYTHONPATH" similar to what is done in above examples. The service file will automatically activate this environment

Neel-rishabhsoft avatar Sep 23 '20 12:09 Neel-rishabhsoft

the .service file must be in /etc/systemd/system

jcalhinho avatar Feb 22 '21 19:02 jcalhinho