From: František Dvořák Date: Fri, 13 Nov 2009 11:23:41 +0000 (+0000) Subject: Simplify notification clean up logic (clean up only manually). X-Git-Tag: glite-security-gss_R_2_0_1_1~11 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=87f591d0ed42dbfc1ea805640b78e6b39ebfc396;p=jra1mw.git Simplify notification clean up logic (clean up only manually). --- diff --git a/org.glite.lb.harvester/doc/README b/org.glite.lb.harvester/doc/README index 25ca987..f1c393d 100644 --- a/org.glite.lb.harvester/doc/README +++ b/org.glite.lb.harvester/doc/README @@ -68,16 +68,14 @@ For example: Stop ==== -There are two "end modes": - -1) temporary: stop and keep all registered notification ids, notifications - are queued in L&B notification daemons for later delivery +In non-daemon mode CTRL-C can be used, in daemon mode using specified +pidfile: kill `cat /var/run/glite-lb-harvester.pid` -2) full stop: with cleanup of the all notification ids +pidfile will vanish after exit. - kill -2 `cat /var/run/glite-lb-harvester.pid` -(or just CTRL-C if not daemonized) +All notifications are preserved on LB servers, and will expire later. You can +purge them now, if they won't be needed: -pidfile will vanish after successful cleaning up and exiting. + glite-lb-harvester --cleanup diff --git a/org.glite.lb.harvester/src/harvester.c b/org.glite.lb.harvester/src/harvester.c index e7ee7ad..8f6ffc6 100644 --- a/org.glite.lb.harvester/src/harvester.c +++ b/org.glite.lb.harvester/src/harvester.c @@ -152,6 +152,7 @@ typedef struct { char *dbcs; // DB connection string char *cert, *key; int ttl; // requested time to live (validity) of the notifications + int cleanup; // if to clean up notifications on LB servers int wlcg; // dashboard messaging int wlcg_no_remove; // don't remove temporary files (for debugging) char *wlcg_binary; // path msg-publish binary @@ -207,6 +208,7 @@ static const struct option opts[] = { { "key", required_argument, NULL, 'K'}, { "wlcg", no_argument, NULL, 'w'}, { "old", no_argument, NULL, 'o'}, + { "cleanup", no_argument, NULL, 'l'}, { NULL, no_argument, NULL, 0} }; @@ -224,6 +226,7 @@ config_t config = { cert: NULL, key: NULL, ttl: RTM_NOTIF_TTL, + cleanup: 0, wlcg: 0, silly: 0, @@ -1754,22 +1757,24 @@ int reconcile_config_db() { edg_wll_Context ctx = NULL; edg_wll_NotifId notifid; - if (config.silly) { - typestart = RTM_NOTIF_TYPE_OLD; - typeend = RTM_NOTIF_TYPE_OLD; - } else { - typestart = RTM_NOTIF_TYPE_STATUS; - typeend = RTM_NOTIF_TYPE_JDL; - } - n = db.n; - for (i = 0; i < config.nservers; i++) { - a = config.notifs + i; - for (type = typestart; type <= typeend; type++) - { - b = db_search_notif_by_server(db.notifs, n, a->server, a->port, type); - if (!b) b = db_add_notif(NULL, type, 0, 0, 0, strdup(a->server), a->port, 1); - else lprintf(NULL, INF, "found previous notification '%s' (%s)", b->id_str, rtm_notiftype2str(b->type)); - b->active = 1; + if (!config.cleanup) { + if (config.silly) { + typestart = RTM_NOTIF_TYPE_OLD; + typeend = RTM_NOTIF_TYPE_OLD; + } else { + typestart = RTM_NOTIF_TYPE_STATUS; + typeend = RTM_NOTIF_TYPE_JDL; + } + n = db.n; + for (i = 0; i < config.nservers; i++) { + a = config.notifs + i; + for (type = typestart; type <= typeend; type++) + { + b = db_search_notif_by_server(db.notifs, n, a->server, a->port, type); + if (!b) b = db_add_notif(NULL, type, 0, 0, 0, strdup(a->server), a->port, 1); + else lprintf(NULL, INF, "found previous notification '%s' (%s)", b->id_str, rtm_notiftype2str(b->type)); + b->active = 1; + } } } @@ -1824,6 +1829,7 @@ void usage(const char *prog) { " -C, --cert X509 certificate file\n" " -K, --key X509 key file\n" " -o, --old \"silly\" mode for old L&B 3.1 servers\n" + " -l, --cleanup clean up the notifications and exit\n" " -w, --wlcg enable messaging for dashboard\n" " --wlcg-binary full path to msg-publish binary\n" " --wlcg-topic topic for msg-publish\n" @@ -1911,6 +1917,9 @@ int config_preload(int argn, char *argv[]) { free(config.key); config.key = strdup(optarg); break; + case 'l': + config.cleanup = 1; + break; case 'w': config.wlcg = 1; break; @@ -2074,15 +2083,9 @@ void handle_signal(int num) { lprintf(NULL, INF, "received signal %d", num); switch (num) { case SIGINT: - quit = RTM_QUIT_CLEANUP; - break; - case SIGTERM: - quit = RTM_QUIT_PRESERVE; - break; - default: - quit = RTM_QUIT_CLEANUP; + quit = RTM_QUIT_PRESERVE; break; } } @@ -2257,8 +2260,13 @@ int main(int argn, char *argv[]) { // load previous notifications if (load_notifs()) goto quit; - // compare lb servers from configuration and notifications - if (reconcile_config_db(&config, &db)) goto quit; + // compare lb servers from configuration and notifications, + // or clean up and exit if specified + if (reconcile_config_db()) goto quit; + if (config.cleanup) { + retval = RTM_EXIT_OK; + goto quit; + } // signal handler sa.sa_handler = handle_signal;