1

replace gunicorn with uwsgi

has an easier-to-work-with prometheus.
This commit is contained in:
2024-01-15 16:14:46 +02:00
parent b983a2f59a
commit 50c34aa922
4 changed files with 33 additions and 27 deletions

View File

@@ -1,10 +1,10 @@
{
writeTextFile,
e11sync-static,
gunicornPort ? 8002,
backendPort ? 8002,
}:
writeTextFile {
name = "e11sync-caddy";
name = "e11sync-frontend";
text = ''
header Strict-Transport-Security "max-age=31536000"
header /static/CACHE/* Cache-Control "public, max-age=31536000, immutable"
@@ -17,6 +17,6 @@ writeTextFile {
}
}
reverse_proxy http://127.0.0.1:${toString gunicornPort}
reverse_proxy http://127.0.0.1:${toString backendPort}
'';
}

View File

@@ -6,7 +6,8 @@
python3Packages,
libmaxminddb,
dart-sass,
gunicornPort ? 8002,
uwsgi,
backendPort ? 8002,
database-path ? null,
geoip-mmdb,
}:
@@ -24,20 +25,22 @@ stdenv.mkDerivation {
buildPhase = ''mkdir -p $out'';
installPhase = ''
cp -r . $out/app
makeWrapper ${python3Packages.gunicorn}/bin/gunicorn $out/bin/e11sync-gunicorn \
makeWrapper $out/app/manage.py $out/bin/e11sync \
--set GEOIP_PATH "${geoip-mmdb}"
makeWrapper ${uwsgi}/bin/uwsgi $out/bin/e11sync-backend \
--chdir $out/app \
--set-default E11SYNC_HTTP_PORT ${toString gunicornPort} \
--set-default E11SYNC_HTTP_PORT ${toString backendPort} \
--add-flags "--plugin ${uwsgi}/lib/uwsgi/python3_plugin.so" \
--add-flags "--http-socket 127.0.0.1:${toString backendPort}" \
--add-flags "--wsgi-file e11sync/wsgi.py" \
--add-flags --master \
${lib.optionalString (database-path != null) ''
--set E11SYNC_DATABASE_PATH "${database-path}" \
''} \
--set E11SYNC_DEBUG "" \
--set E11SYNC_COMPRESS_OFFLINE 1 \
--set GEOIP_PATH "${geoip-mmdb}" \
--add-flags --bind=127.0.0.1:\$E11SYNC_HTTP_PORT \
--add-flags e11sync.wsgi
makeWrapper $out/app/manage.py $out/bin/e11sync \
--set GEOIP_PATH "${geoip-mmdb}"
'';
passthru.tests.unit =
runCommand "e11sync-test" {