fixes
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
**/__pycache__/*
|
||||
venv/*
|
||||
production/*
|
||||
test*
|
||||
test*
|
||||
logs/*
|
||||
6
Makefile
6
Makefile
@@ -1,6 +1,10 @@
|
||||
|
||||
build:
|
||||
@:
|
||||
if [ ! -d venv ]; then
|
||||
python3 -m venv venv
|
||||
fi
|
||||
venv/bin/pip install requirements.txt
|
||||
|
||||
|
||||
deploy:
|
||||
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"
|
||||
|
||||
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,
|
||||
env=dict(
|
||||
os.environ,
|
||||
|
||||
13
deploy.sh
13
deploy.sh
@@ -1,16 +1,19 @@
|
||||
#!/bin/bash
|
||||
deploydir=$DEPLOYERDIR/$REPO/$BRANCH
|
||||
|
||||
mkdir -p $deploydir
|
||||
mkdir -p $deploydir/src
|
||||
cd $deploydir
|
||||
|
||||
git clone $CLONE_URL .
|
||||
git clone $CLONE_URL ./src
|
||||
|
||||
cd src
|
||||
git fetch origin $BRANCH
|
||||
git reset --hard origin/$BRANCH
|
||||
git checkout $COMMIT_HASH
|
||||
|
||||
make build
|
||||
|
||||
cd ..
|
||||
echo "
|
||||
[Unit]
|
||||
Description=Deployment of $REPO/$BRANCH
|
||||
@@ -20,7 +23,7 @@ After=network.target
|
||||
Type=simple
|
||||
ExecStart=make deploy
|
||||
User=drm
|
||||
WorkingDirectory=$deploydir
|
||||
WorkingDirectory=$deploydir/src
|
||||
Restart=on-failure
|
||||
StandardOutput=file:$deploydir/server.log
|
||||
StandardError=file:$deploydir/server.log
|
||||
@@ -28,11 +31,11 @@ StandardError=file:$deploydir/server.log
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
" > deploy.service
|
||||
systemctl daemon-reload
|
||||
|
||||
service="deployer-$REPO-$BRANCH.service"
|
||||
echo /etc/systemd/system/$service
|
||||
ln -s $deploydir/deploy.service /etc/systemd/system/$service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
systemctl stop $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