/* running standalone. we want to ignore plugin versions. */
service->version_string = NULL;
}
- if ((service->flags & MASTER_SERVICE_FLAG_SEND_STATS) != 0 &&
- service->stats_client == NULL &&
- service->set->stats_writer_socket_path[0] != '\0') T_BEGIN {
- const char *path = t_strdup_printf("%s/%s",
- service->set->base_dir,
- service->set->stats_writer_socket_path);
+ if ((service->flags & MASTER_SERVICE_FLAG_SEND_STATS) != 0) {
/* When running standalone (e.g. doveadm) try to connect to the
stats socket, but don't log an error if it's not running.
It may be intentional. */
bool silent_notfound_errors =
(service->flags & MASTER_SERVICE_FLAG_STANDALONE) != 0;
- service->stats_client =
- stats_client_init(path, silent_notfound_errors);
- } T_END;
+ master_service_init_stats_client(service, silent_notfound_errors);
+ }
if (service->set->shutdown_clients)
master_service_set_die_with_master(master_service, TRUE);
service->log_initialized = TRUE;
}
+void master_service_init_stats_client(struct master_service *service,
+ bool silent_notfound_errors)
+{
+ if (service->stats_client == NULL &&
+ service->set->stats_writer_socket_path[0] != '\0') T_BEGIN {
+ const char *path = t_strdup_printf("%s/%s",
+ service->set->base_dir,
+ service->set->stats_writer_socket_path);
+ service->stats_client =
+ stats_client_init(path, silent_notfound_errors);
+ } T_END;
+}
+
void master_service_set_die_with_master(struct master_service *service,
bool set)
{
functions. The following calls change the log prefix. */
void master_service_init_log(struct master_service *service,
const char *prefix);
+/* Initialize stats client (if it's not already initialized). This is called
+ automatically if MASTER_SERVICE_FLAG_SEND_STATS is enabled. If
+ silent_notfound_errors is set, connect() errors aren't logged if they're
+ happening because the stats service isn't running. */
+void master_service_init_stats_client(struct master_service *service,
+ bool silent_notfound_errors);
/* If set, die immediately when connection to master is lost.
Normally all existing clients are handled first. */