You are not logged in.

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

rodaz143
Member
From: WA, USA
Registered: 2013-07-24
Posts: 92
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?


"It can only be attributable to human error."
-HAL 9000

Offline

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

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,052
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)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

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

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 4,324

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.


Booting with apg Openrc, NOT systemd.
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

Board footer

Powered by FluxBB