-
Notifications
You must be signed in to change notification settings - Fork 2
Deploy with Supervisor
Berg Paulo edited this page Apr 9, 2021
·
13 revisions
Obs: Assuming it was installed Raspberry Pi OS (32-bit) with desktop
version:
Maybe with other version, be necessary install another dependencies.
sudo apt install python3-venv supervisor
- Clone project,
- Enter in project folder,
- Create a virtualenv:
python3 -m venv .venv
, - Activate virtualenv:
source .venv/bin/activate
, - Install python dependencies:
pip install -r requirements_prod.txt
, - Create a .env file in root of project and add FLASK_ENV and SECRET_KEY variables with your values.
- FLASK_ENV - Flask environment, development or production. Ex: FLASK_ENV=development
- SECRET_KEY - Your secret key into app. Ex: SECRET_KEY=your_secret_key
- Run
flask db init && flask db migrate && flask db upgrade && flask seed
to run migrations and create admin user, - Run server:
gunicorn wsgi:app --worker-class eventlet -w 1 --timeout 120 --no-sendfile -b 0.0.0.0:8000
, - Access http://your_ip:8000,
- Lisa is up.
- Running with supervisor you have many options to control application execution.
This configuration starts application with O.S. start, and restarts automatically if something going wrong.
Change
pi
with your system user.
sudo nano /etc/supervisor/conf.d/lisapi.conf
[program:lisapi]
command = /home/pi/lisapi/.venv/bin/gunicorn wsgi:app --worker-class eventlet -w 1 --timeout 120 --no-sendfile -b 0.0.0.0:8000
directory = /home/pi/lisapi
user = pi
autostart = true
stderr_logfile = /var/log/supervisor/lisapi-stderr.log
stdout_logfile = /var/log/supervisor/lisapi-stdout.log
-
Save file.
-
Restart
supervisor
configurations:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl restart lisapi
- Access http://your_ip:8000 to open application.