plug_systemd_example
plug_systemd_example copied to clipboard
Example Elixir application that integrates with systemd features
This project was merged into systemd library examples.
Plug systemd Example
This is example of Plug+Cowboy application that integrates with systemd via systemd library features like:
- Socket activation to listen on privileged port port (80) while VM running
as unprivileged user
www-data - Journal logging, which allows for structured logging and multiline logs
- Watchdog integration which allows for triggering restarts from within application
- Status notifications where application reports readiness when it is really ready and will inform when the application is in process of shutting down
ASCIICinema recording of shutdown handling:
Installation
This project require Elixir 1.10+ for logger integration and OTP 23+ for
proper socket support
- Clone repo.
- Run
make(you will need to entersudopassword for installation of systemd units). - Application will be available at http://localhost/.
Endpoints
/- return OS PID of VM/slow- wait 5s before sending response/hello- respond with stringworld/stop- trigger Watchdog/reload- simulate application reload that last 10s