__pmServerNotifyServiceManagerReady - Man Page

notify service start and stop

C Synopsis

#include "pmapi.h"
#include "libpcp.h"

int __pmServerNotifyServiceManagerReady(pid_t mainpid);
int __pmServerNotifyServiceManagerStopping(pid_t mainpid);

cc ... -lpcp

Caveat

This documentation is intended for internal Performance Co-Pilot (PCP) developer use.

These interfaces are not part of the PCP APIs that are guaranteed to remain fixed across releases, and they may not work, or may provide different semantics at some point in the future.

Description

Within the libraries and applications of the Performance Co-Pilot (PCP) these routines provide a convenient and portable interface to service manager APIs, such as sd_notify(3).

PCP service daemons should call __pmServerNotifyServiceManagerReady immediately prior to entering their main loop, regardless of whether or not they have forked or daemonised. This will notify the service manager (if any, depending on the platform) that the daemon service has started, and that the main process to be tracked is mainpid.

Similarly when shutting down, service daemons should call __pmServerNotifyServiceManagerStopping to notify the service manager (if any) that the tracked process of the service has returned from it's main loop and is about to shut down.

These routines are intended to be portable and thus no conditional code should be needed for any service daemon on any platform.

Diagnostics

These functions will print diagnostics to the stderr stream if pmDebugOptions.services is set.

Return Code

If successful, __pmServerNotifyServiceManagerReady returns a positive integer that depends on the platform service manager. In the case of systemd(1), the return code is from sd_notify(3). If the platform supports systemd(1) but the NOTIFY_SOCKET environment variable is not set (as may be the case if the server program is started manually rather than by systemd(1)), the return code will be PM_ERR_GENERIC which will normally be ignored but a diagnostic will be printed if pmDebugOptions.services is set. On platforms that have no service manager, the return code will be PM_ERR_NYI. For backward compatibility on these platforms, the return code should be ignored.

Referenced By

pmlogger(1).

The man page __pmServerNotifyServiceManagerStopping(3) is an alias of __pmServerNotifyServiceManagerReady(3).

PCP Performance Co-Pilot