Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 고유값
- Gunicorn
- NLP
- GPT API
- GPU
- 매매봇
- DataLoader
- overloaed
- leetcode
- Python #for문 #while문 #응애
- ML
- UUID
- python
- ML #머신러닝
- GCP
- Mecab
- 파이썬 #기초 #응애
- docker
- Flask
- Anaconda
- BitCoin
- Backoff
- MySQL
- onnx #openvino #tf2onnx #openvinokeras
- GPT
- pytorch
- vram
- CentOS
- Python #open #read #파이썬
- OpenAI
Archives
- Today
- Total
람쥐썬더
[PYTHON] FLASK - GUNICORN 본문
flask 를 백엔드로 서버를 열어주는 과정
centos 7.9 에서 작업한 내용 정리인데 ubuntu 도 크게 다르진 않다
Anaconda 환경에서 작업하는 내용 기준이며 gunicorn 경로만 설정해주면 되기 때문에 크게 복잡하지는 않음
Gunicorn
1. gunicorn pip 설치
pip install gunicorn
2. gunicorn.service 구성
2.1 gunicorn.service 생성
sudo vi /etc/systemd/system/gunicorn.service
2.2 gunicorn.service 설정
[Unit]
Description=Gunicorn Flask
After=network.target
[Service]
User=centos # Gunicorn을 실행할 사용자 이름으로 변경
Group=centos # Gunicorn을 실행할 그룹 이름으로 변경
WorkingDirectory=/home/centos/myweb # flask main 파일이 담긴 경로
ExecStart= # gunicorn 경로 및 실행 명령
[Install]
WantedBy=multi-user.target
ExecStart 는 anaconda3 기준 경로와 실행 명령을 입력해 주면 된다
예)
ExecStart=/home/centos/anaconda3/envs/flask/bin/gunicorn --preload -w 3 --bind 0.0.0.0:8000 application:app --reload
flask라는 가상환겨 내에 설치된 gunicorn을 뒤에 명령어를 추가해 ( prelaod, bind, reload , log .. ) 실행해준다
3. 리로드 및 실행
sudo systemctl daemon-reload
sudo systemctl enable gunicorn
sudo systemctl start gunicorn
이게 생각보다 쉬운데 은근 까다로움..
'파이썬' 카테고리의 다른 글
[PYTHON] Vercel Flask 배포 (0) | 2024.05.11 |
---|---|
[PYTHON] 애매한 random 보다 uuid (0) | 2024.02.22 |
[PYTHON] PYTORCH 이미지 DataLoader 구축 플로우 정리 (0) | 2023.11.20 |
[PYTHON] AttributeError: module 'openai' has no attribute 'ChatCompletion' (0) | 2023.11.07 |
[Leetcode] 1337. The K Weakest Rows in a Matrix (0) | 2023.09.18 |