deploy files
parent
686d3262f8
commit
5fb567715a
@ -0,0 +1,20 @@
|
||||
test:
|
||||
python3 main.py
|
||||
pip:
|
||||
sudo pip3 install -r requirements.txt
|
||||
deploy: pip
|
||||
cp sample.service new.service
|
||||
# yes, this exists because I'm too lazy to escape regex + inline 'sed'
|
||||
python3 sed.py
|
||||
sudo mv new.service /etc/systemd/system/webforge.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now webforge.service
|
||||
undeploy:
|
||||
sudo systemctl stop webforge.service
|
||||
sudo systemctl disable webforge.service
|
||||
sudo rm /etc/systemd/system/webforge.service
|
||||
sudo systemctl daemon-reload
|
||||
update:
|
||||
make undeploy
|
||||
git pull
|
||||
make deploy
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Localizer gunicorn service
|
||||
|
||||
[Service]
|
||||
# WHO is edited by sed.py to become the current user
|
||||
User=WHO
|
||||
Type=simple
|
||||
# GCPATH is edited by sed.py to point to the user's installation of gunicorn
|
||||
# PATH becomes the output of `pwd`
|
||||
ExecStart=GCPATH --chdir PATH --workers=8 --bind=0.0.0.0 main:app
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,18 @@
|
||||
import os, subprocess, getpass
|
||||
|
||||
# Feel free to edit this file, but note that `make deploy` expects the service file to be output as `new.service`
|
||||
# It, of course, is renamed to `localizer.service` as it's moved to `/etc/systemd/system/`
|
||||
|
||||
text = open("new.service").read()
|
||||
text = text.replace(
|
||||
"GCPATH",
|
||||
subprocess.check_output(["/usr/bin/bash", "-c", "which gunicorn"])
|
||||
.decode("utf-8")
|
||||
.strip(),
|
||||
)
|
||||
text = text.replace("PATH", os.getcwd())
|
||||
text = text.replace("WHO", getpass.getuser())
|
||||
|
||||
os.remove("new.service")
|
||||
with open("new.service", "w") as f:
|
||||
f.write(text)
|
Loading…
Reference in New Issue