In java, I need to make a unix daemon. So I need to create the sockets and then fork, so that systemd knows that the service is actually ready.
In C, this is normally done like this:
int main() {
initialise_socket();
daemon(0,0);
}
So that when the process terminates, systemd (or upstart, or sysvinit) know that the daemon is ready to accept connections, and daemons that depend on it can now be started.
My question is: how can I do this in java?
I have googled around and found a lot of misguided advice about starting java using nohup
, which in no way does what I need to do.