1

I've setup and configured Apache Superset, but I can't get it to run as a Systemd Service.

I've tried setting it up in a virtualenv and using systemd like this, but I still get an error about gunicorn not being available and the unit fails to start.

I've also tried creating a separate user for Superset, installing Superset and its dependencies with pip install --user, the unit then looks like:

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

[Service]
User=superset
ExecStart=/home/superset/.local/bin/superset runserver

[Install]
WantedBy=multi-user.target

and it still doesn't work. Looking at the journal

Jul 13 22:54:21 radioactive-man systemd[1]: Started Superset.
Jul 13 22:54:23 radioactive-man superset[24023]: 2018-07-13 22:54:23,893:INFO:root:The Gunicorn 'superset runserver' command is deprecated. Please use the 'gunicorn' command instead.
Jul 13 22:54:23 radioactive-man superset[24023]: /bin/sh: 1: gunicorn: not found
Jul 13 22:54:23 radioactive-man superset[24023]: Starting server with command:
Jul 13 22:54:23 radioactive-man superset[24023]: gunicorn -w 2 --timeout 60 -b  0.0.0.0:8088 --limit-request-line 0 --limit-request-field_size 0 superset:app
Jul 13 22:54:23 radioactive-man superset[24023]:

running the command at bash it works fine.

Environment Info

Ubuntu Linux 16.04

Superset 0.26.3

2

Most of the times when a file exists on your system and you get an Error message stating it wasn't found this means the OS doesn't find the file in you $PATH environment variable.

The easiest way to make your OS find gunicorn is to put gunicorn under /usr/local/bin, something that is in the default path.

Adding its location to your path will only be taken into account by your active session, once you close it, it will be gone, unless you put it in /etc/environment file and reboot.

You can also configure the service environment:

  • Create a directory under /etc/systemd/system/<service_name>.service.d
  • Create a file under the newly created directory and configure the service environment like below:

    $ vim /etc/systemd/system/<service_name>.service.d/file.conf
    
    [Service]
    Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/path_to_directory_containing_gunicorn
    

    Esc:wq

Note: Since The file we added is no shell script, it doesn t support variable expansion

writing PATH=$PATH:/path_to_directory_containing_gunicorn WILL NOT WORK As expected

  • reload the units configuration

    $ systemctl daemon-reload
    
  • Thanks! That's a super detailed answer. I actually just symlinked gunicorn to /usr/local/bin and it worked. – aphid Jul 15 '18 at 0:47
  • 1
    I should note that Environment= does not expand variables in assignments. "The $ character has no special meaning." – grawity Jul 20 '18 at 5:22
  • @grawity Thank you for comment, i will check it and update accordingly – Ezwig Jul 20 '18 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.