Create web.service - #8
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new systemd unit to run the webapp process as a service with a dependency on database.service.
Changes:
- Introduces
systemd/system/web.servicewith aType=notifyservice definition. - Adds a database dependency via
Requires=database.service. - Defines the
ExecStartcommand for launching the web application.
|
|
||
| [Service] | ||
| Type=notify | ||
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 |
There was a problem hiding this comment.
TimeoutStartSec and TimeoutStopSec are not set. Relying on systemd defaults can hang boot/shutdown for a long time if the service gets stuck starting or stopping; please specify explicit timeouts per the repo guidance.
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 | |
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 | |
| TimeoutStartSec=30 | |
| TimeoutStopSec=10 |
|
|
||
| [Service] | ||
| Type=notify | ||
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 |
There was a problem hiding this comment.
For a long-running Type=notify service, consider adding an ExecReload= command so configuration can be reloaded without a full restart (where supported by the process).
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 | |
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 | |
| ExecReload=/bin/kill -HUP $MAINPID |
| @@ -0,0 +1,7 @@ | |||
| [Unit] | |||
| Description=Web Application Service | |||
| Requires=database.service | |||
There was a problem hiding this comment.
Requires=database.service pulls in the dependency but does not guarantee ordering. Add After=database.service so web.service won’t attempt DB connections before database.service has started.
| Requires=database.service | |
| Requires=database.service | |
| After=database.service |
|
|
||
| [Service] | ||
| Type=notify | ||
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 |
There was a problem hiding this comment.
The unit is missing an [Install] section (e.g., WantedBy=multi-user.target). Without it, systemctl enable web.service won’t create target symlinks and the service may not auto-start at boot unless something else pulls it in.
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 | |
| ExecStart=/usr/bin/webapp --db-connect localhost:5432 | |
| [Install] | |
| WantedBy=multi-user.target |
| Description=Web Application Service | ||
| Requires=database.service | ||
|
|
||
| [Service] |
There was a problem hiding this comment.
This systemd unit defines a [Service] without a User= directive, so the web application will run as root by default. Any remote code execution or configuration flaw in webapp would immediately yield full system compromise instead of being contained to an unprivileged account. Configure a dedicated non-privileged service user here and ensure the unit runs under that account.
| [Service] | |
| [Service] | |
| User=webapp |
sync changes
| @@ -0,0 +1,7 @@ | |||
| [Unit] | |||
| Description=Web Application Service | |||
There was a problem hiding this comment.
Description is quite generic; please make it more specific to what this web service actually provides (e.g., product/component name and responsibility).
| Description=Web Application Service | |
| Description=webapp HTTP front-end service providing the application's web API backed by the database |
No description provided.