in MacOs and linux world you create daemons, not services.
macOs daemon
linux daemon
http://shahmirj.com/blog/beginners-guide-to-creating-a-daemon-in-linux
on MacOs (and freebsd), you configure launchd with launchctl
https://www.launchd.info
https://ss64.com/osx/launchctl.html
on linux it will depend on the distro used. some use service, but others use systemd
https://man7.org/linux/man-pages/man5/systemd.service.5.html
https://www.linux.com/training-tutorials/understanding-and-using-systemd/
note: on MacOs and Linux, you'd typically fork, and run a configuration utility rather than call a library to configure startup applications. Often this is done by the installation script.