I was eventually able to get something working by writing a wrapper script that calls nifi.sh start, then enters a loop looking for a 200 response from the health page (http://127.0.0.1:${HEALTH_PORT}/health). Thereafter it checks every 10 seconds to make sure the health page is up. This keeps the 'service' alive for systemd.
Service definition (not sure how much of it is really needed): [Unit] Description=Apache NiFi After=network.target [Service] Type=simple User=nifi Group=nifi WorkingDirectory=/opt/nifi/nifi-2.3.0 ExecStart=/opt/nifi/nifi-2.3.0/bin/nifi-systemd-wrapper.sh ExecStop=/opt/nifi/nifi-2.3.0/bin/nifi.sh stop Environment=JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 Environment=NIFI_HOME=/opt/nifi/nifi-2.3.0 Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin TimeoutStartSec=300 TimeoutStopSec=60 Restart=on-failure RestartSec=20s LimitNOFILE=65536 [Install] WantedBy=multi-user.target I could make the wrapper script available too if anyone wants it. Thanks, Dave ________________________________ From: Rafael Fracasso Sent: Wednesday, April 30, 2025 2:38 PM To: users@nifi.apache.org Subject: Re: Installation as a service on Ubuntu VM [cid:inky-injection-inliner-6f42d488d348cfcd86bff9497caf9f6a] External (rafaelfraca...@gmail.com<mailto:rafaelfraca...@gmail.com>) [cid:inky-injection-inliner-7e39dc2e793139f8cd8ed7952d9d36b1] Report This Email<https://protection.inkyphishfence.com/report?id=c2tvdXQtY2xldmVyLWRldmljZXMvZGdhbGxhZ2hlckBjbGV2ZXJkZXZpY2VzLmNvbS8wNmJkYjM3YzM5MGNjM2FhMGNkY2ZhNmI0ZmI4YmZhMy8xNzQ2MDM4NDExLjM4NDA2NTk=#key=d8f0eb07310d39c1010bf0beb02bf664> M365 Quarantine<https://security.microsoft.com/quarantine> Protection by Clever Devices<https://www.inky.com/protection-by-inky> can you search in nifi-app.log and nifi-bootstrap.log something like OutOfMemoryError, Permission denied, Port already in use, Unable to create application context also check in bootstrap.conf the Xms and Xmx config if they are compatible with how much RAM you have on the server. Em qua., 30 de abr. de 2025 às 13:16, David Gallagher <dgallag...@cleverdevices.com<mailto:dgallag...@cleverdevices.com>> escreveu: Thanks, Heiko! But, when I use that definition it starts the service and immediately terminates it. Apr 30 16:35:46 clever-nifi systemd[1]: Starting nifi.service - Apache NiFi... Apr 30 16:35:46 clever-nifi nifi.sh<http://nifi.sh/>[2576]: JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 Apr 30 16:35:46 clever-nifi nifi.sh<http://nifi.sh/>[2576]: NIFI_HOME=/opt/nifi/nifi-2.3.0 Apr 30 16:35:47 clever-nifi systemd[1]: Started nifi.service - Apache NiFi. Apr 30 16:36:47 clever-nifi systemd[1]: nifi.service: Deactivated successfully. Apr 30 16:36:47 clever-nifi systemd[1]: nifi.service: Consumed 3.656s CPU time, 128.4M memory peak, 0B memory swap peak. Dave ________________________________ From: Gawehn, Heiko Sent: Wednesday, April 30, 2025 1:18 AM To: users@nifi.apache.org<mailto:users@nifi.apache.org> Subject: RE: Installation as a service on Ubuntu VM Hi David, this is how it works with my Debian based installation. [Unit] Description=Apache Nifi After=network.target [Service] Type=forking ExecStart=/opt/nifi/bin/nifi.sh start [Install] WantedBy=multi-user.target Regards Heiko From: David Gallagher <dgallag...@cleverdevices.com<mailto:dgallag...@cleverdevices.com>> Sent: Wednesday, April 30, 2025 12:07 AM To: users@nifi.apache.org<mailto:users@nifi.apache.org> Subject: Installation as a service on Ubuntu VM You don't often get email from dgallag...@cleverdevices.com<mailto:dgallag...@cleverdevices.com>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification> Hi - is there any guidance on how to create a systemd service definition for NiFi 2.x? I'm finding it very difficult to create a working one, and a lot of the advice online is apparently very out of date. Thanks, Dave