새로 만든 파이썬 자동화 파일 가상머신에 업로드하기

YongjLEE·2023년 8월 7일
0

새로만든 파이썬 자동화 파일 가상머신에 업로드하기

서버

sudo apt update
sudo apt install python3-pip

로컬

git init
git add main.py
git commit -m "initial commit"
git remote add origin https://github.com/usingjun/chatgptService.git
git push -u origin main

서버

git clone https://github.com/usingjun/chatgptService.git
sudo apt install python3-virtualenv
virtualenv venv
cd chatgptSerice
source venv/bin/activate

로컬

git push

서버

git pull
pip install -r requirements.txt

서버 위치 ~/chatgptService

백그라운드(포그라운드이면서) 서버 돌리는법

screen -R chatgpt => chatgpt라는 이름의 screen만 만들어짐
source venv/bin/activate

vi ~/.bashrc //환경변수
젤 밑에 export 값들 복붙

export OPENAI_API_KEY='자신의 openapikey'
export MYSQL_HOST='자신의 데이터베이스 서버이름'
export MYSQL_PORT=3306
export MYSQL_USER='sbb_root'
export MYSQL_USER_PASSWORD='자신의 데이터베이스 패스워드'
source ~/.bashrc //환경변수 반영

python main.py

ctrl +A +D //나갈 때, detach 모드
screen -R chatgpt//다시 들어갈 때

profile
이용준의 블로그입니다.

2개의 댓글

comment-user-thumbnail
2023년 8월 7일

큰 도움이 되었습니다, 감사합니다.

1개의 답글