Until recently, the approach would be to write an
init script and
install it as part of application installation. Of course not all distros are LSB compliant so custom futzing may be necessary.
Now with some distributions moving to systemd, this may not be the right way to do things for those distros (supposedly systemd will interpret an LSB init script, but in practice... seems tricky). You may be better off writing a
service file for those.
I don't have first-hand experience so can't provide guidance on the easiest way to approach things. My impression is this will be an ugly task no matter which path you take and all you can do is minimize the pain. But then I'm a pessimist.