if you use Termux to host your service, then you can "Acquire wakelock" to keep it available with the screen off. That's an action-button attached to the Termux notification, and I believe also the main reason Termux has a notification (to trick android into not background-killing it).
I have some quickstart notes here: https://ocv.me/termux/