I'm fairly new to Linux
I need to create a Java process that is an orphan (not a child of any process) and it needs to either be a service or have a unique process name so that I can stop it whenever I like.
Basically I'm trying to get Gitlab to deploy a Java server from CI. Every CI build needs to identify and kill a server instance if one is already running, and make a new one. (The server must also run as an orphan or else the CI build gets stuck waiting for the server to terminate.)
Sure, I can just kill all running Java processes but I'd like a cleaner way in case I ever have a Java process running that is not the server.
I tried to make an alias but bash doesn't see it unless I try the alias in terminal. (How to create a service on Ubuntu Upstart I also tried using a function by inserting into .bashrc and .bash_aliases by following instructions from How to run an alias in a shell script? to check if it would work like an alias and have a custom process name but it also failed.
I would make a service but I'm new to Linux and don't know how, plus the directory where the jar is stored changes every build. I don't know how I would pass the directory to the service so that Java knows what it's running.