}
const char *ctdb_eventscript_call_names[] = {
+ "init",
"startup",
"startrecovery",
"recovered",
loadconfig
case "$1" in
- startup)
+ init)
# make sure we have a blank state directory for the scripts to work with
/bin/rm -rf $CTDB_BASE/state
/bin/mkdir -p $CTDB_BASE/state
loadconfig
case "$1" in
- startup)
+ init)
ctdb_counter_init
;;
case "$1" in
#############################
# called when ctdbd starts up
- startup)
+ init)
# make sure that we only respond to ARP messages from the NIC where
# a particular ip address is associated.
[ -f /proc/sys/net/ipv4/conf/all/arp_filter ] && {
called with the ctdb daemon in NORMAL mode (ie. not in recovery)
The events currently implemented are
-startup
+init
This event does not take any additional arguments.
This event is only invoked once, when ctdb is starting up.
- This event is used to wait for the service to start and all
- resources for the service becoming available.
+ This event is used to do some cleanup work from earlier runs
+ and prepare the basic setup.
+
+ Example: 00.ctdb cleans up $CTDB_BASE/state
+
+startup
+ This event does not take any additional arguments.
+ This event is only invoked once, when ctdb has finished
+ the initial recoveries. This event is used to wait for
+ the service to start and all resources for the service
+ becoming available.
This is used to prevent ctdb from starting up and advertize its
services until all dependent services have become available.
# or do something else ...
;;
startup)
-# do some extra magic when ctdb has started?
+ # do some extra magic when ctdb has finished the initial
+ # recovery?
+ ;;
+
+ init)
+ # do some extra magic when ctdb has started?
;;
esac
/* different calls to event scripts. */
enum ctdb_eventscript_call {
- CTDB_EVENT_STARTUP, /* CTDB starting up: no args. */
+ CTDB_EVENT_INIT, /* CTDB starting up: no args */
+ CTDB_EVENT_STARTUP, /* CTDB starting up after initial recovery: no args. */
CTDB_EVENT_START_RECOVERY, /* CTDB recovery starting: no args. */
CTDB_EVENT_RECOVERED, /* CTDB recovery finished: no args. */
CTDB_EVENT_TAKE_IP, /* IP taken: interface, IP address, netmask bits. */
int num_healthy_nodes);
int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
+void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
+
void ctdb_fault_setup(void);
#endif
ctdb_fatal(ctdb, "Failed to get initial freeze\n");
}
+ ret = ctdb_event_script(ctdb, CTDB_EVENT_INIT);
+ if (ret != 0) {
+ ctdb_fatal(ctdb, "Failed to run init event\n");
+ }
+ ctdb_run_notification_script(ctdb, "init");
+
/* now start accepting clients, only can do this once frozen */
fde = event_add_fd(ctdb->ev, ctdb, ctdb->daemon.sd,
EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
return ret;
}
-static void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event)
+void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event)
{
pid_t child;
{
switch (call) {
/* These all take no arguments. */
+ case CTDB_EVENT_INIT:
case CTDB_EVENT_STARTUP:
case CTDB_EVENT_START_RECOVERY:
case CTDB_EVENT_RECOVERED:
/* we guarantee that only some specifically allowed event scripts are run
while in recovery */
const enum ctdb_eventscript_call allowed_calls[] = {
- CTDB_EVENT_START_RECOVERY, CTDB_EVENT_SHUTDOWN, CTDB_EVENT_RELEASE_IP, CTDB_EVENT_STOPPED };
+ CTDB_EVENT_INIT,
+ CTDB_EVENT_START_RECOVERY,
+ CTDB_EVENT_SHUTDOWN,
+ CTDB_EVENT_RELEASE_IP,
+ CTDB_EVENT_STOPPED
+ };
int i;
for (i=0;i<ARRAY_SIZE(allowed_calls);i++) {
if (call == allowed_calls[i]) break;
exit 0;
;;
+ init)
+ echo "ctdb init event"
+ exit 0;
+ ;;
startup)
echo "ctdb startup event"
exit 0;