Skip to content

Commit

Permalink
Don't fail seeder if no services are configured/enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Mar 4, 2016
1 parent c0d67ba commit 7a38423
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions apache/mod_mapcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ static const char* mapcache_add_alias(cmd_parms *cmd, void *cfg, const char *ali
if(GC_HAS_ERROR(ctx)) {
return ctx->get_error_message(ctx);
}
if(mapcache_config_services_enabled(ctx, alias_entry->cfg) <= 0) {
return "no mapcache <service>s configured/enabled, no point in continuing.";
}
APR_ARRAY_PUSH(sconfig->aliases,mapcache_alias_entry*) = alias_entry;
ap_log_error(APLOG_MARK, APLOG_INFO, 0, cmd->server, "loaded mapcache configuration file from %s on endpoint %s", alias_entry->configfile, alias_entry->endpoint);

Expand Down
4 changes: 4 additions & 0 deletions cgi/mapcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ static void load_config(mapcache_context *ctx, char *filename)
if(GC_HAS_ERROR(ctx)) goto failed_load;
mapcache_configuration_post_config(ctx, cfg);
if(GC_HAS_ERROR(ctx)) goto failed_load;
if(mapcache_config_services_enabled(ctx,cfg) <= 0) {
ctx->set_error(ctx,500,"no mapcache <service>s configured/enabled, no point in continuing.");
goto failed_load;
}

/* no error, destroy the previous pool if we are reloading the config */
if(config_pool) {
Expand Down
4 changes: 4 additions & 0 deletions include/mapcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ MS_DLL_EXPORT void mapcache_service_dispatch_request(mapcache_context *ctx,
char *pathinfo,
apr_table_t *params,
mapcache_cfg *config);
/**
* \brief return the number of enabled/configured services
*/
MS_DLL_EXPORT int mapcache_config_services_enabled(mapcache_context *ctx, mapcache_cfg *config);


/** @} */
Expand Down
2 changes: 0 additions & 2 deletions lib/configuration_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,6 @@ void mapcache_configuration_parse_xml(mapcache_context *ctx, const char *filenam
} else if ((node = ezxml_child(doc,"services")) != NULL) {
ctx->log(ctx,MAPCACHE_WARN,"<services> tag is deprecated, use <service type=\"wms\" enabled=\"true|false\">");
parseServices(ctx, node, config);
} else {
ctx->set_error(ctx, 400, "no <services> configured");
}
if(GC_HAS_ERROR(ctx)) goto cleanup;

Expand Down
1 change: 0 additions & 1 deletion lib/service_wmts.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ void _create_capabilities_wmts(mapcache_context *ctx, mapcache_request_get_capab
int j;
for(j=0; j<grid_link->grid->nlevels; j++) {
ezxml_t matrixlimits = ezxml_add_child(limits,"TileMatrixLimits",0);
int row;
ezxml_set_txt(ezxml_add_child(matrixlimits,"TileMatrix",0),
apr_psprintf(ctx->pool,"%s:%d",grid_link->grid->name,j));
ezxml_set_txt(ezxml_add_child(matrixlimits,"MinTileRow",0),
Expand Down
9 changes: 9 additions & 0 deletions lib/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ void mapcache_service_dispatch_request(mapcache_context *ctx, mapcache_request *
ctx->set_error(ctx,404,"unknown service %s",pathinfo);
}

int mapcache_config_services_enabled(mapcache_context *ctx, mapcache_cfg *config) {
int count=0,i;
for(i=0; i<MAPCACHE_SERVICES_COUNT; i++) {
if(config->services[i])
count++;
}
return count;
}

/** @} */


Expand Down
4 changes: 4 additions & 0 deletions nginx/ngx_http_mapcache_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ ngx_http_mapcache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,ctx->get_error_message(ctx));
return NGX_CONF_ERROR;
}
if(mapcache_config_services_enabled(ctx, ctx->config) <= 0) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "no mapcache <service>s configured/enabled, no point in continuing.");
return NGX_CONF_ERROR;
}
mapcache_connection_pool_create(&ctx->connection_pool,ctx->pool);
ctx->config->non_blocking = 1;

Expand Down

0 comments on commit 7a38423

Please sign in to comment.