root/src/utils/noit_watchdog.h

Revision 5b63423e3ea22c19a8187dfcce162d43e0159643, 3.6 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

pull out the watchdog stuff into utils and integrate it back into noitd and now into stratcond, refs #131

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2005-2007, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *    * Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  *    * Redistributions in binary form must reproduce the above
12  *      copyright notice, this list of conditions and the following
13  *      disclaimer in the documentation and/or other materials provided
14  *      with the distribution.
15  *    * Neither the name OmniTI Computer Consulting, Inc. nor the names
16  *      of its contributors may be used to endorse or promote products
17  *      derived from this software without specific prior written
18  *      permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef _NOIT_WATCHDOG_H
34 #define _NOIT_WATCHDOG_H
35
36 #include "noit_config.h"
37 #include "noit_defines.h"
38
39 /*! \fn int noit_watchdog_prefork_init()
40     \brief Prepare the program to split into a child/parent-monitor relationship.
41     \return Returns zero on success.
42 .
43    
44     noit_watchdog_prefork_init sets up the necessary plumbing to bridge across a
45 child to instrument watchdogs.
46  */
47 API_EXPORT(int)
48   noit_watchdog_prefork_init();
49
50 /*! \fn int noit_watchdog_start_child(const char *app, int (*func)(), int timeout)
51     \brief Starts a function as a separate child under close watch.
52     \param app The name of the application (for error output).
53     \param func The function that will be the child process.
54     \param timeout The number of seconds of lifelessness before the parent reaps and restarts the child.
55     \return Returns on program termination.
56 .
57    
58     noit_watchdog_start_child will fork and run the specified function in the child process.  The parent will watch.  The child process must initialize the eventer system and then call noit_watchdog_child_hearbeat to let the parent know it is alive.  If the eventer system is being used to drive the child process, noit_watchdog_child_eventer_heartbeat may be called once after the eventer is initalized.  This will induce a regular heartbeat.
59  */
60 API_EXPORT(int)
61   noit_watchdog_start_child(const char *app, int (*func)(), int timeout);
62
63 /*! \fn int noit_watchdog_child_heartbeat()
64     \return Returns zero on success
65
66     noit_watchdog_child_heartbeat is called within the child function to alert the parent that the child is still alive and functioning correctly.
67  */
68 API_EXPORT(int)
69   noit_watchdog_child_heartbeat();
70
71 /*! \fn int noit_watchdog_child_eventer_heartbeat()
72     \return Returns zero on success
73
74     noit_watchdog_child_eventer_heartbeat registers a periodic heartbeat through the eventer subsystem.  The eventer must be initialized before calling this function.
75  */
76 API_EXPORT(int)
77   noit_watchdog_child_eventer_heartbeat();
78
79 #endif
Note: See TracBrowser for help on using the browser.