This sounds like a Linux question about init systems rather than an Ansible question.
I'd suggest asking about how to tailor your init script on a site like StackOverflow* or reading up on the documentation for upstart, SysV, or whatever you are using.
These are usually pretty straightforward, but not cross-Linux in nature - you'll probably need to template your init script or package a couple of them to account for OS differences.
* = note StackOverflow isn't great for AnsibleQuestions, this list is definitely better for that