Metad - a daemon for controlling daemons

11 June 2006, 10:13 UTC

As I progress in winding up my position at the Computing Support Group at cse.unsw I'm looking for programs that I wrote which might be more widely useful and trying to make them available to the open source community.

One such is 'metad' which you can find in my git repository at git://neil.brown.name/metad or http://neil.brown.name/git/?p=metad.

metad is a daemon for managing other daemons. It is a bit like inetd in that it starts programs and waits for them to complete. However it isn't just starting programs based on network activity - that is possible, but was a later addition.

The main purpose is to run all other little daemons one seems to need and to allow those daemons to be stopped and started remotely. It may not be very interesting on a single-user machine, but it is wonderful when administering a network

# Introduction
# The daemon type
# The stream type
# Remote Control
# TODO list

Introduction

Metad reads a config file /etc/metad.conf which describes a number of services. Each service has a name, a type, a number of options and a program and argument list.

Currently there are two types of services, daemon and stream.

The daemon type

A daemon is normally expected to be running all the time. If a daemon dies, it is normally restarted, though if it dies very soon after being started, an exponential backoff is used to stop it running out of control. Multiple instances of a daemon can be running concurrently.

A daemon can have a minimum number of instances (if there are few than this, one is started), a maximum (if there are this many no more will be started) and a period (an attempt is made to start one every period). Daemons can also be started remotely.

The stream type

A stream service is started when an incoming TCP connection is attempted on a particular port. There can be a maximum number of processes for a particular service, but no minimum.

If processes die quickly (with a non-zero exit code), then like daemons, they appear to hang around for an exponentially growing length of time, so if something is wrong, they will not restart constantly. I find that the upper limit on concurrent number together with the exponential backoff is much more useful that inetd's very simplistic rate limiting.

Remote Control

metad comes with a program called metac which allows control of services. They can be listed, disabled, enabled, started and killed remotely. The action requests can be broadcast on a subnet, and a remote server can be asked to rebroadcast a request. This a request can be fairly easily broadcast around multiple subnets.

TODO list

There is plenty of room for further enhancements to metad that were not done because we didn't have a real need. They include:






[æ]