Skip to content

quarkiverse/quarkus-systemd-notify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

223 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quarkus Systemd Notify Extension

All Contributors

Version

Introduction

This extension is used to notify Linux service manager (systemd) about start-up completion and other service status changes.

Usage

To use the extension, add the dependency to the target project:

<dependency>
    <groupId>io.quarkiverse.systemd.notify</groupId>
    <artifactId>quarkus-systemd-notify</artifactId>
    <version>${quarkus.systemd.notify.version}</version>
</dependency>

and configure the service unit file with the following minumum configurations:

...

[Service]
Type=notify
AmbientCapabilities=CAP_SYS_ADMIN

...

Systemd Service Example

Assuming quarkus-run.jar is located at /opt/quarkus-app/quarkus-run.jar:

  • Create a unit configuration file at /etc/systemd/system/quarkus.service:
[Unit]
Description=Quarkus Server
After=network.target
Wants=network.target

[Service]
Type=notify
NotifyAccess=all
AmbientCapabilities=CAP_SYS_ADMIN
ExecStart=/bin/java -jar /opt/quarkus-app/quarkus-run.jar
SuccessExitStatus=0 143

[Install]
WantedBy=multi-user.target
  • Enable the service (this will make it to run at system start-up as well):
sudo systemctl enable quarkus
  • Start/Stop/Restart the service:
sudo systemctl start quarkus
sudo systemctl stop quarkus
sudo systemctl restart quarkus
  • Check status of the service:
sudo systemctl status quarkus

systemd-notify with SELinux

If SELinux (Mostly for RedHat OS) is enabled:

root# getenforce
Enforcing

Add systemd_notify_t to the permissive types:

semanage permissive -a systemd_notify_t

You can check with:

semanage permissive -l

You may need to execute this as well:

sudo /sbin/restorecon -v /etc/systemd/system/quarkus.service

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Fouad Almalki
Fouad Almalki

💻 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

About

This project demonstrates integrating systemd-notify with Quarkus

Topics

Resources

License

Stars

Watchers

Forks

Contributors 6

Languages