You are not logged in.

#1 2013-11-01 21:15:13

rodaz143
Member
Registered: 2013-07-24
Posts: 95
Website

Creating a service for a daemon

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

service gochan

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?

Offline

#2 2013-11-01 21:31:43

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: Creating a service for a daemon

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)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2013-11-02 12:02:50

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: Creating a service for a daemon

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.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

Board footer

Powered by FluxBB