I'm working on a specialized server daemon in Google's Go language, and have a makefile that I want to have an "install" directive for, that would pu the compiled binary, the document root, the logfile directory, etc, in /opt/gochan/*, and create a service that can be started by running
systemctl start gochan
in distros using systemd
in distros using Upstart, etc.
How would I go about doing this? What is the best way to make a catch-all method of starting it as a service?
"It can only be attributable to human error."
Why install to /opt? Why not use the distro's prefered $PREFIX and/or $BINDIR?
As for systemd service files, there is a wiki page or a man page for that - they are pretty simple. The upstart equivalent may be in the *buntoo documentation.
Is the real question here just how to detect which init is used from within a Makefile? Autotools would probably be the best way. But a check of /proc/1/comm would be an effective shortcut.
EDIT: from another perspective, though, distro specific things should be handled by the packaging for that distro. Your makefile should just allow for different options. So the systemd service file could be installed via a PKGBUILD or the *buntoo equivalent, or perhaps with different install directives like `make install.systemd` and `make install.upstart`.
Last edited by Trilby (2013-11-01 21:35:17)
rodaz143, https://aur.archlinux.org/packages/profile-sync-daemon/ (developed by graysky) can be build for systemd , upstart and openrc using build-time options .
It might serve as an example of how to do what you want.
Booting with apg Openrc, NOT systemd.
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them