Skip to content

Integration with services

Fabrice Bacchella edited this page Nov 20, 2025 · 1 revision

Integrating LogHub with systemd on Linux and Apache Procrun on Windows

LogHub can run as a native service on both Linux and Windows. The application detects the operating system and uses systemd on Linux or Apache Procrun on Windows by implementing the appropriate service interfaces.

1. systemd Integration (Linux)

1.1 General Approach

LogHub will detect that it run under systemd and expose status information via sd_notify.

1.2 Recommended systemd unit

[Unit]
Description=LogHub Service
After=network-online.target

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/loghub
ExecStart=.../bin/java ... -jar .../loghub.jar -c .../loghub.conf
User=loghub
TimeoutSec=30
Restart=on-failure
RestartPreventExitStatus=10 11 12

[Install]
WantedBy=multi-user.target

2. Apache Procrun Integration (Windows)

2.1 General Approach

Apache Procrun allows a Java application to be installed and run as a Windows Service. LogHub provides:

  • A startup class with a windowsStart method.
  • A shutdown class with a windowsStop method.

These methods are invoked by Procrun depending on the service lifecycle.

2.2 Example Procrun Configuration (prunsrv)

Below is an example using prunsrv.exe to install the service:

prunsrv //IS//MyApp ^
  --DisplayName="LogHub" ^
  --Description="LogHub" ^
  --Install="C:\\procrun\\prunsrv.exe" ^
  --Jvm=auto ^
  --StartMode=jvm ^
  --StopMode=jvm ^
  --Classpath="...\\loghub.jar" ^
  --StartClass=loghub.ProcrunHandler ^
  --StartMethod=windowsStart ^
  --StopClass=loghub.ProcrunHandler ^
  --StopMethod=windowsStop ^
  --LogPath="...\\loghub.log" ^
  --StdOutput=auto ^
  --StdError=auto

2.3 Example Procrun XML Configuration

Some deployments prefer an XML-based configuration consumed by wrapper scripts:

<Service>
  <Id>LogHub</Id>
  <Name>LogHub</Name>
  <Description>LogHub</Description>
  <LogPath>...\logs</LogPath>

  <Executable>C:\procrun\prunsrv.exe</Executable>

  <Options>
    <Option name="Jvm">auto</Option>
    <Option name="StartMode">jvm</Option>
    <Option name="StopMode">jvm</Option>
    <Option name="Classpath">...\\loghub.jar</Option>
    <Option name="StartClass">loghub.ProcrunHandler</Option>
    <Option name="StartMethod">windowsStart</Option>
    <Option name="StopClass">loghub.ProcrunHandler</Option>
    <Option name="StopMethod">windowsStop</Option>
  </Options>
</Service>

Clone this wiki locally