From 2af7ce58f100ef1f0dcc888965ef21b5996e5a49 Mon Sep 17 00:00:00 2001 From: Natalie Fearnley Date: Fri, 7 Jun 2024 16:21:04 -0400 Subject: [PATCH] update build scripts for easier deployment --- build.sh | 18 ++++++++++-------- old_build.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 8 +++++++- 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 old_build.sh diff --git a/build.sh b/build.sh index 86408e3e..18c82ab2 100644 --- a/build.sh +++ b/build.sh @@ -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}; @@ -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=$?;\ @@ -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; diff --git a/old_build.sh b/old_build.sh new file mode 100644 index 00000000..a63e04d3 --- /dev/null +++ b/old_build.sh @@ -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; diff --git a/pyproject.toml b/pyproject.toml index 7a7859e7..0ecf4cf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ @@ -107,4 +113,4 @@ select = [ ignore = ["E501", "COM812", "PIE790", "RET504", "RUF001", "RUF013"] [tool.ruff.lint.pep8-naming] -ignore-names = ["fromJSON", "toJSON"] \ No newline at end of file +ignore-names = ["fromJSON", "toJSON"]