superset icon indicating copy to clipboard operation
superset copied to clipboard

Cannot login when server is starting by systemd service

Open henry145145 opened this issue 6 years ago • 4 comments

Hi, I am currently trying to install superset inside an AWS EC2 instance

My superset version is 0.35.1, python is 3.7.4 I made three changes inside /usr/local/lib/python3.7/site-packages/superset/config.py

  • add mapbox key
  • enable proxy fix = true
  • enable redis cache

After I install superset, I ran the following command:

superset db upgrade
export FLASK_APP=superset
flask fab create-admin
superset init
superset run -h 0.0.0.0 -p 8080 --reload --debugger

After that, I was able to login to superset using the admin account I created through flask fab create-admin

Then, I am trying to set up auto restart and here is my superset.service

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

[Service]
Restart=always
Type=simple
ExecStart=/usr/local/bin/superset run -h 0.0.0.0 -p 8080 --reload --debugger

[Install]
WantedBy=multi-user.target

I ran sudo service superset start and sudo service superset status and things look ok

● superset.service - Superset service
   Loaded: loaded (/etc/systemd/system/superset.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-12-30 18:22:04 UTC; 5min ago
 Main PID: 15224 (superset)
   CGroup: /system.slice/superset.service
           ├─15224 /usr/bin/python3 /usr/local/bin/superset run -h 0.0.0.0 -p 8080 --reload --debugger
           └─15232 /usr/bin/python3 /usr/local/bin/superset run -h 0.0.0.0 -p 8080 --reload --debugger

I was able to go to the superset login page, however, I was not able to login using the admin account above (it return "Invalid login. Please try again.").

Then, I stop the serivce and manually run superset run -h 0.0.0.0 -p 8080 --reload --debugger and I was able to login again.

My guess is that when the server is starting by systemd, it is not recognizing /home/ec2-user/.superset/superset.db. If that is the case, then how do I point it to the correct db?

henry145145 avatar Dec 30 '19 18:12 henry145145

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

issue-label-bot[bot] avatar Dec 30 '19 18:12 issue-label-bot[bot]

I think you can set it to run as a user (as opposed to root) by setting

User=ec2-user

in your systemd service. Otherwise, I assume it looks for the superset.db in /.superset/, not in /home/ec2-user/.superset.

guidopetri avatar Jan 06 '20 05:01 guidopetri

I think you can set it to run as a user (as opposed to root) by setting

User=ec2-user

in your systemd service. Otherwise, I assume it looks for the superset.db in /.superset/, not in /home/ec2-user/.superset.

@charlesoblack Thank you so much! It works!

henry145145 avatar Jan 06 '20 18:01 henry145145

For anyone else with a similar issue and is running it on virtualenv with gunicorn: You need to set your working directory and environment path. See instructions here for more details.

[Unit]
Description=Gunicorn instance to serve myproject
After=network.target

[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/venv
Environment="PATH=/home/ubuntu/venv/bin"
ExecStart=/home/ubuntu/venv/bin/gunicorn -c /home/ubuntu/venv/gunicorn_config.py "superset.app:create_app()"

[Install]
WantedBy=multi-user.target

jjgong7 avatar Jul 26 '20 05:07 jjgong7