Skip to content

Commit

Permalink
update build scripts for easier deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
nfearnley committed Jun 7, 2024
1 parent f972ade commit 2af7ce5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
18 changes: 10 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
echo ------------BEGIN-------------;
branch=$1
botname=$2
if [ "$branch" -eq "master" ]; then
botname="sizebot"
elif [ "$branch" -eq "develop" ]; then
botname="nizebot"
else; then
echo "Unrecognized branch: ${branch}";
exit 1
fi
botservice=${botname}
apiservice=${botname}api
dest=~/envs/${branch}

export PIPENV_YES=1;

echo =============STOP=============;
systemctl --user stop ${apiservice};
systemctl --user stop ${botservice};
Expand All @@ -15,11 +20,8 @@ echo ============BUILD=============;
rm -rf "${dest}";
mkdir "${dest}";
cd "${dest}" &&
~/.local/bin/pipenv --rm &&
git clone --depth=1 -b ${branch} https://github.com/sizedev/SizeBot.git . &&
~/.local/bin/pipenv install . &&
~/.local/bin/pipenv run pip install cysystemd &&
~/.local/bin/pipenv run pip install uwsgi &&
rye sync --no-dev --features=linux &&
systemctl --user start ${botservice} &&
systemctl --user start ${apiservice};
code=$?;\
Expand All @@ -29,7 +31,7 @@ systemctl --user status ${botservice};
systemctl --user status ${apiservice};

echo =============LOG==============;
journalctl --user -u ${botservice} --since "$(systemctl show -p InactiveExitTimestamp --value --user ${botservice})";\
journalctl --user -u ${botservice} --since "$(systemctl show -p InactiveExitTimestamp --value --user ${botservice})";

echo -------------END--------------;
exit $code;
42 changes: 42 additions & 0 deletions old_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
echo ------------BEGIN-------------;
branch=$1
if [ "$branch" -eq "master" ]; then
botname="sizebot"
elif [ "$branch" -eq "develop" ]; then
botname="nizebot"
else; then
echo "Unrecognized branch: ${branch}";
exit 1
fi
botservice=${botname}
apiservice=${botname}api
dest=~/envs/${branch}

export PIPENV_YES=1;

echo =============STOP=============;
systemctl --user stop ${apiservice};
systemctl --user stop ${botservice};

echo ============BUILD=============;
rm -rf "${dest}";
mkdir "${dest}";
cd "${dest}" &&
~/.local/bin/pipenv --rm &&
git clone --depth=1 -b ${branch} https://github.com/sizedev/SizeBot.git . &&
~/.local/bin/pipenv install . &&
~/.local/bin/pipenv run pip install cysystemd &&
~/.local/bin/pipenv run pip install uwsgi &&
systemctl --user start ${botservice} &&
systemctl --user start ${apiservice};
code=$?;\

echo ============STATUS============;
systemctl --user status ${botservice};
systemctl --user status ${apiservice};

echo =============LOG==============;
journalctl --user -u ${botservice} --since "$(systemctl show -p InactiveExitTimestamp --value --user ${botservice})";

echo -------------END--------------;
exit $code;
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ dependencies = [
"numexpr==2.9.0",
]

[project.optional-dependencies]
linux = [
"cysystemd>=1.6.2",
"uwsgi>=2.0.26",
]

[tool.rye]
managed = true
dev-dependencies = [
Expand Down Expand Up @@ -107,4 +113,4 @@ select = [
ignore = ["E501", "COM812", "PIE790", "RET504", "RUF001", "RUF013"]

[tool.ruff.lint.pep8-naming]
ignore-names = ["fromJSON", "toJSON"]
ignore-names = ["fromJSON", "toJSON"]

0 comments on commit 2af7ce5

Please sign in to comment.