Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch default to granian #1987

Merged
merged 5 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rocky/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ RUN export SECRET_KEY="secret" BYTES_API="http://bytes:8000" BYTES_PASSWORD="pas

USER rocky

CMD ["uwsgi", "--ini", "uwsgi.ini", "--wsgi-file", "rocky/wsgi.py"]
CMD ["granian", "--interface", "wsgi", "rocky.wsgi:application", "--host", "0.0.0.0"]
3 changes: 1 addition & 2 deletions rocky/debian/kat-rocky.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ SyslogIdentifier=kat-rocky
WorkingDirectory=/opt/venvs/kat-rocky/
EnvironmentFile=/usr/lib/kat/rocky.defaults
EnvironmentFile=/etc/kat/rocky.conf
ExecStart=/opt/venvs/kat-rocky/bin/uwsgi --ini /etc/kat/rocky.uwsgi.ini
ExecStart=/opt/venvs/kat-rocky/bin/granian --interface wsgi rocky.wsgi:application
Restart=on-failure
RestartSec=3s
KillSignal=SIGQUIT
KillMode=mixed
Type=notify
NotifyAccess=all

[Install]
Expand Down
17 changes: 6 additions & 11 deletions rocky/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ if [ "$1" = "configure" ]; then
# Set SECRET_KEY if empty
key=$(tr -dc A-Za-z0-9 < /dev/urandom | head -c 64)
sed -i "s/SECRET_KEY= *\$/SECRET_KEY=${key}/" /etc/kat/rocky.conf

# Only configure granian for new installs. Existing installations will
# switch in the next release.
mkdir -p /etc/systemd/system/kat-rocky.service.d
cat > /etc/systemd/system/kat-rocky.service.d/use-granian.conf << EOF
# Do not customize this file because it will be automatically removed in the next release
[Service]
ExecStart=
ExecStart=/opt/venvs/kat-rocky/bin/granian --interface wsgi rocky.wsgi:application
Type=simple
EOF
fi

# Delete file and directory that was added in 1.13 to use granian only on
# new installs.
if [ -d /etc/systemd/system/kat-rocky.service.d ]; then
rm -f /etc/systemd/system/kat-rocky.service.d/use-granian.conf
rmdir --ignore-fail-on-non-empty /etc/systemd/system/kat-rocky.service.d
fi
fi

#DEBHELPER#
Expand Down
6 changes: 1 addition & 5 deletions rocky/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ if [ "$DATABASE_MIGRATION" = "1" ] || [[ $DATABASE_MIGRATION == "true" ]]; then
python manage.py migrate --noinput
fi

if [ "$1" == "uwsgi" ] && { [ "$USE_GRANIAN" = "1" ] || [[ $USE_GRANIAN == "true" ]]; }; then
exec granian --interface wsgi rocky.wsgi:application --host 0.0.0.0
else
exec "$@"
fi
exec "$@"