fixes
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
**/__pycache__/*
|
**/__pycache__/*
|
||||||
venv/*
|
venv/*
|
||||||
production/*
|
production/*
|
||||||
test*
|
test*
|
||||||
|
logs/*
|
||||||
6
Makefile
6
Makefile
@@ -1,6 +1,10 @@
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
@:
|
if [ ! -d venv ]; then
|
||||||
|
python3 -m venv venv
|
||||||
|
fi
|
||||||
|
venv/bin/pip install requirements.txt
|
||||||
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
venv/bin/waitress-serve --host 0.0.0.0 --port 5000 listen:app
|
venv/bin/waitress-serve --host 0.0.0.0 --port 5000 listen:app
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ def handle_request(rq: DeployerRequest):
|
|||||||
log_file = f"{log_folder}/{int(time())}.log"
|
log_file = f"{log_folder}/{int(time())}.log"
|
||||||
|
|
||||||
subprocess.Popen(
|
subprocess.Popen(
|
||||||
f"sudo -E ./deploy.sh > {log_file} >2 {log_file}",
|
["./deploy.sh"],
|
||||||
|
user="root",
|
||||||
|
stdout=open(log_file, "w"),
|
||||||
|
stderr=open(log_file, "a"),
|
||||||
shell=True,
|
shell=True,
|
||||||
env=dict(
|
env=dict(
|
||||||
os.environ,
|
os.environ,
|
||||||
|
|||||||
13
deploy.sh
13
deploy.sh
@@ -1,16 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
deploydir=$DEPLOYERDIR/$REPO/$BRANCH
|
deploydir=$DEPLOYERDIR/$REPO/$BRANCH
|
||||||
|
|
||||||
mkdir -p $deploydir
|
mkdir -p $deploydir/src
|
||||||
cd $deploydir
|
cd $deploydir
|
||||||
|
|
||||||
git clone $CLONE_URL .
|
git clone $CLONE_URL ./src
|
||||||
|
|
||||||
|
cd src
|
||||||
git fetch origin $BRANCH
|
git fetch origin $BRANCH
|
||||||
git reset --hard origin/$BRANCH
|
git reset --hard origin/$BRANCH
|
||||||
git checkout $COMMIT_HASH
|
git checkout $COMMIT_HASH
|
||||||
|
|
||||||
make build
|
make build
|
||||||
|
|
||||||
|
cd ..
|
||||||
echo "
|
echo "
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Deployment of $REPO/$BRANCH
|
Description=Deployment of $REPO/$BRANCH
|
||||||
@@ -20,7 +23,7 @@ After=network.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=make deploy
|
ExecStart=make deploy
|
||||||
User=drm
|
User=drm
|
||||||
WorkingDirectory=$deploydir
|
WorkingDirectory=$deploydir/src
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
StandardOutput=file:$deploydir/server.log
|
StandardOutput=file:$deploydir/server.log
|
||||||
StandardError=file:$deploydir/server.log
|
StandardError=file:$deploydir/server.log
|
||||||
@@ -28,11 +31,11 @@ StandardError=file:$deploydir/server.log
|
|||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
" > deploy.service
|
" > deploy.service
|
||||||
systemctl daemon-reload
|
|
||||||
|
|
||||||
service="deployer-$REPO-$BRANCH.service"
|
service="deployer-$REPO-$BRANCH.service"
|
||||||
echo /etc/systemd/system/$service
|
|
||||||
ln -s $deploydir/deploy.service /etc/systemd/system/$service
|
ln -s $deploydir/deploy.service /etc/systemd/system/$service
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
systemctl stop $service
|
systemctl stop $service
|
||||||
systemctl start $service
|
systemctl start $service
|
||||||
|
|
||||||
|
|||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
flask
|
||||||
|
waitress
|
||||||
Reference in New Issue
Block a user