I'd try `bin/nifi.sh run` with a Type=simple service. It will block while NiFi is running and exit when NiFi dies. It will however not differentiate between starting and started states, but I'm assuming your health check script doesn't do that either.
Marton -------- Original Message -------- On 4/30/25 21:58, David Gallagher wrote: > 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 > > 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> 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 >> 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> >> Sent: Wednesday, April 30, 2025 12:07 AM >> To:users@nifi.apache.org >> Subject: Installation as a service on Ubuntu VM >> >> You don't often get email from 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