diff options
author | pacien | 2021-07-29 23:09:30 +0200 |
---|---|---|
committer | pacien | 2021-07-29 23:09:30 +0200 |
commit | 07a5b7d436d9be68a3c04e3584777e8ab6eac016 (patch) | |
tree | b22a2be2e386c69dd9c28ac7f76d85a6df7fc2ed | |
parent | d8ebf148dda8d5e7fae5906568aa01e98aa4cc23 (diff) | |
download | uge_l2_rdbms_python_proto-07a5b7d436d9be68a3c04e3584777e8ab6eac016.tar.gz |
flake: add app server package output
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | flake.nix | 10 | ||||
-rw-r--r-- | readme.md | 14 |
3 files changed, 25 insertions, 0 deletions
@@ -1,5 +1,6 @@ | |||
1 | __pycache__ | 1 | __pycache__ |
2 | development_database | 2 | development_database |
3 | result | ||
3 | *~ | 4 | *~ |
4 | *.swp | 5 | *.swp |
5 | *.swo | 6 | *.swo |
@@ -92,6 +92,16 @@ | |||
92 | 92 | ||
93 | in { | 93 | in { |
94 | 94 | ||
95 | packages = { | ||
96 | # Minimal production server. | ||
97 | # This includes only application files tracked by git. | ||
98 | # Using `gunicorn` on top of `uvicorn` is recommended for bigger loads. | ||
99 | server = writeShellScript "server" '' | ||
100 | cd ${./.} | ||
101 | ${pythonWithDependencies}/bin/uvicorn --app-dir app app:main "$@" | ||
102 | ''; | ||
103 | }; | ||
104 | |||
95 | devShell = mkShell rec { | 105 | devShell = mkShell rec { |
96 | buildInputs = [ pythonWithDependencies ] ++ develPackagesAndScripts; | 106 | buildInputs = [ pythonWithDependencies ] ++ develPackagesAndScripts; |
97 | 107 | ||
@@ -342,6 +342,20 @@ This server will listen to incoming requests to a locally bound port. It will | |||
342 | automatically reload itself when its files are edited, and display logs about | 342 | automatically reload itself when its files are edited, and display logs about |
343 | type checking and runtime errors. | 343 | type checking and runtime errors. |
344 | 344 | ||
345 | ### Production deployment | ||
346 | |||
347 | While the deployment phase is way out of the scope of a database introductory | ||
348 | course, asking students to deploy their application on the Internet could be a | ||
349 | motivational factor. It would also facilitate evaluating and grading projects, | ||
350 | avoiding deployment and testing hassles to the teaching staff. | ||
351 | |||
352 | The Nix Flake provides a Nix package which can be used to run the web | ||
353 | application in a production context as a [daemon], managed by a standard [init] | ||
354 | system. | ||
355 | |||
356 | [daemon]: https://en.wikipedia.org/wiki/Daemon_(computing) | ||
357 | [init]: https://en.wikipedia.org/wiki/Init | ||
358 | |||
345 | 359 | ||
346 | ## Copyright and licensing | 360 | ## Copyright and licensing |
347 | 361 | ||