Skip to content

Commit

Permalink
Switch default to granian (#1987)
Browse files Browse the repository at this point in the history
Co-authored-by: ammar92 <[email protected]>
Co-authored-by: Jan Klopper <[email protected]>
  • Loading branch information
3 people authored Nov 13, 2023
1 parent 7e6fa2b commit c59fee1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
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 "$@"

0 comments on commit c59fee1

Please sign in to comment.