Skip to content

Commit

Permalink
Move renderd.conf processing code into new file (#391)
Browse files Browse the repository at this point in the history
So that it can be easily re-used by other targets.
  • Loading branch information
hummeltech authored Feb 18, 2024
1 parent fdaa5a5 commit 1c9f8b6
Show file tree
Hide file tree
Showing 14 changed files with 639 additions and 449 deletions.
64 changes: 28 additions & 36 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = $(PTHREAD_CFLAGS) $(GLIB_CFLAGS)

STORE_SOURCES = \
src/g_logger.c \
src/store.c \
src/store_file.c \
src/store_file_utils.c \
src/store_memcached.c \
src/store_null.c \
src/store_rados.c \
src/store_ro_http_proxy.c \
src/store_ro_composite.c \
src/store_null.c \
src/g_logger.c
src/store_ro_http_proxy.c
STORE_LDFLAGS = $(LIBMEMCACHED_LDFLAGS) $(LIBRADOS_LDFLAGS) $(LIBCURL) $(GLIB_LIBS)

STORE_CPPFLAGS =
Expand All @@ -22,8 +22,8 @@ bin_PROGRAMS = \
renderd \
render_expired \
render_list \
render_speedtest \
render_old
render_old \
render_speedtest
noinst_PROGRAMS = gen_tile_test

man_MANS = \
Expand All @@ -38,32 +38,33 @@ renderddir = $(sysconfdir)

renderd_SOURCES = \
src/renderd.c \
src/cache_expire.c \
src/daemon_compat.c \
src/gen_tile.cpp \
src/sys_utils.c \
src/request_queue.c \
src/cache_expire.c \
src/metatile.cpp \
src/parameterize_style.cpp \
src/protocol_helper.c \
src/renderd_config.c \
src/request_queue.c \
src/sys_utils.c \
$(STORE_SOURCES)
renderd_CXXFLAGS = $(MAPNIK_CFLAGS)
renderd_LDADD = $(PTHREAD_CFLAGS) $(MAPNIK_LDFLAGS) $(STORE_LDFLAGS) $(INIPARSER_LDFLAGS)
renderd_DATA = etc/renderd/renderd.conf
renderd_LDADD = $(PTHREAD_CFLAGS) $(MAPNIK_LDFLAGS) $(STORE_LDFLAGS) $(INIPARSER_LDFLAGS)

render_speedtest_SOURCES = \
src/render_speedtest.cpp \
src/g_logger.c \
src/protocol_helper.c \
src/render_submit_queue.c \
src/sys_utils.c \
src/g_logger.c
src/sys_utils.c
render_speedtest_LDADD = $(PTHREAD_CFLAGS) $(GLIB_LIBS)

render_list_SOURCES = \
src/render_list.c \
src/sys_utils.c \
src/protocol_helper.c \
src/render_submit_queue.c \
src/sys_utils.c \
$(STORE_SOURCES)
render_list_LDADD = $(PTHREAD_CFLAGS) $(STORE_LDFLAGS)

Expand All @@ -76,31 +77,22 @@ render_expired_SOURCES = \
render_expired_LDADD = $(PTHREAD_CFLAGS) $(STORE_LDFLAGS)

render_old_SOURCES = \
src/store_file_utils.c \
src/render_old.c \
src/sys_utils.c \
src/g_logger.c \
src/protocol_helper.c \
src/render_submit_queue.c \
src/g_logger.c
src/store_file_utils.c \
src/sys_utils.c
render_old_LDADD = $(PTHREAD_CFLAGS) $(GLIB_LIBS)

#convert_meta_SOURCES = src/dir_utils.c src/store.c src/convert_meta.c

gen_tile_test_SOURCES = \
tests/gen_tile_test.cpp \
src/metatile.cpp \
src/request_queue.c \
src/protocol_helper.c \
src/renderd.c \
src/daemon_compat.c \
src/gen_tile.cpp \
src/sys_utils.c \
src/cache_expire.c \
src/parameterize_style.cpp \
$(STORE_SOURCES)
gen_tile_test_CFLAGS = -DMAIN_ALREADY_DEFINED $(PTHREAD_CFLAGS) $(GLIB_CFLAGS)
gen_tile_test_CXXFLAGS = $(MAPNIK_CFLAGS)
gen_tile_test_LDADD = $(PTHREAD_CFLAGS) $(MAPNIK_LDFLAGS) $(STORE_LDFLAGS) $(INIPARSER_LDFLAGS)
$(renderd_SOURCES)
gen_tile_test_CFLAGS = -DMAIN_ALREADY_DEFINED
gen_tile_test_CXXFLAGS = $(renderd_CXXFLAGS)
gen_tile_test_LDADD = $(renderd_LDADD)

CLEANFILES=*.slo mod_tile.la stderr.out src/*.slo src/*.lo src/.libs/* src/*.la

Expand All @@ -114,16 +106,16 @@ all-local:
$(subst -pthread,-Wc$(COMMA)-pthread,$(GLIB_CFLAGS)) \
-I@srcdir@/includes $(AM_LDFLAGS) $(STORE_LDFLAGS) \
@srcdir@/src/mod_tile.c \
@srcdir@/src/sys_utils.c \
@srcdir@/src/g_logger.c \
@srcdir@/src/store.c \
@srcdir@/src/store_file.c \
@srcdir@/src/store_file_utils.c \
@srcdir@/src/store_memcached.c \
@srcdir@/src/store_null.c \
@srcdir@/src/store_rados.c \
@srcdir@/src/store_ro_http_proxy.c \
@srcdir@/src/store_ro_composite.c \
@srcdir@/src/store_null.c \
@srcdir@/src/g_logger.c
@srcdir@/src/store_ro_http_proxy.c \
@srcdir@/src/sys_utils.c

install-mod_tile:
mkdir -p $(DESTDIR)`$(APXS) -q LIBEXECDIR`
Expand All @@ -132,13 +124,13 @@ install-mod_tile:
$(subst -pthread,-Wc$(COMMA)-pthread,$(GLIB_CFLAGS)) \
-I@srcdir@/includes $(AM_LDFLAGS) $(STORE_LDFLAGS) \
@srcdir@/src/mod_tile.c \
@srcdir@/src/sys_utils.c \
@srcdir@/src/g_logger.c \
@srcdir@/src/store.c \
@srcdir@/src/store_file.c \
@srcdir@/src/store_file_utils.c \
@srcdir@/src/store_memcached.c \
@srcdir@/src/store_null.c \
@srcdir@/src/store_rados.c \
@srcdir@/src/store_ro_http_proxy.c \
@srcdir@/src/store_ro_composite.c \
@srcdir@/src/store_null.c \
@srcdir@/src/g_logger.c
@srcdir@/src/store_ro_http_proxy.c \
@srcdir@/src/sys_utils.c
46 changes: 25 additions & 21 deletions includes/renderd.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,49 @@ extern "C" {
int daemon(int nochdir, int noclose);
#endif

#include <limits.h> /* for PATH_MAX */
#include "gen_tile.h"
#include "protocol.h"
#include <limits.h>

#define INILINE_MAX 256
#define MAX_SLAVES 5

typedef struct {
const char *iphostname;
const char *mapnik_font_dir;
const char *mapnik_plugins_dir;
const char *pid_filename;
const char *socketname;
const char *stats_filename;
const char *tile_dir;
char *iphostname;
char *mapnik_font_dir;
char *mapnik_plugins_dir;
char *pid_filename;
char *socketname;
char *stats_filename;
char *tile_dir;
int ipport;
int mapnik_font_dir_recurse;
int num_threads;
} renderd_config;

typedef struct {
char xmlname[XMLCONFIG_MAX];
char xmlfile[PATH_MAX];
char xmluri[PATH_MAX];
char host[PATH_MAX];
char htcpip[PATH_MAX];
char tile_dir[PATH_MAX];
char output_format[INILINE_MAX];
char parameterization[PATH_MAX];
int tile_px_size;
char *attribution;
char *cors;
char *description;
char *host;
char *htcpip;
char *output_format;
char *parameterization;
char *server_alias;
char *tile_dir;
char *xmlfile;
char *xmlname;
char *xmluri;
double scale_factor;
int min_zoom;
int aspect_x;
int aspect_y;
int max_zoom;
int min_zoom;
int num_threads;
int tile_px_size;
} xmlconfigitem;



extern struct request_queue * render_request_queue;
extern struct request_queue *render_request_queue;

void statsRenderFinish(int z, long time);
void request_exit(void);
Expand Down
39 changes: 39 additions & 0 deletions includes/renderd_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2007 - 2024 by mod_tile contributors (see AUTHORS file)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; If not, see http://www.gnu.org/licenses/.
*/

#ifndef RENDERD_CONFIG_H
#define RENDERD_CONFIG_H

#include "render_config.h"
#include "renderd.h"

#ifdef __cplusplus
extern "C" {
#endif

extern int num_slave_threads;
extern renderd_config config;
extern renderd_config config_slaves[MAX_SLAVES];
extern xmlconfigitem maps[XMLCONFIGS_MAX];

int min_max_int_opt(const char *opt_arg, const char *opt_type_name, int minimum, int maximum);
void process_config_file(const char *config_file_name, int active_slave, int log_level);

#ifdef __cplusplus
}
#endif
#endif
8 changes: 8 additions & 0 deletions includes/sys_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#ifndef SYS_UTILS_H
#define SYS_UTILS_H

#ifdef __cplusplus
extern "C" {
#endif

double get_load_avg(void);

#ifdef __cplusplus
}
#endif

#endif
14 changes: 7 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ set(COMMON_LIBRARIES
)

set(STORE_SRCS
store_file_utils.c
store.c
store_file.c
store_file_utils.c
store_memcached.c
store_null.c
store_rados.c
store_ro_composite.c
store_ro_http_proxy.c
store.c
)
set(STORE_LIBRARIES
${CAIRO_LIBRARIES}
Expand Down Expand Up @@ -168,6 +168,7 @@ set(renderd_SRCS
parameterize_style.cpp
protocol_helper.c
renderd.c
renderd_config.c
request_queue.c
)
set(renderd_LIBS
Expand All @@ -180,13 +181,13 @@ set(renderd_LIBS
add_executable(renderd ${renderd_SRCS})
target_link_libraries(renderd ${renderd_LIBS})

if(ENABLE_TESTS)
#-----------------------------------------------------------------------------
#
# Test targets
#
#-----------------------------------------------------------------------------

if(ENABLE_TESTS)
#-----------------------------------------------------------------------------
#
# gen_tile_test
Expand All @@ -201,10 +202,9 @@ set(gen_tile_test_LIBS
${renderd_LIBS}
)
add_executable(gen_tile_test ${gen_tile_test_SRCS})
target_compile_options(gen_tile_test PRIVATE -DMAIN_ALREADY_DEFINED)
target_compile_definitions(gen_tile_test PRIVATE MAIN_ALREADY_DEFINED)
target_include_directories(gen_tile_test PRIVATE ${PROJECT_SOURCE_DIR}/tests)
target_link_libraries(gen_tile_test ${gen_tile_test_LIBS})
set_target_properties(gen_tile_test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests
)
set_target_properties(gen_tile_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests)

endif()
6 changes: 3 additions & 3 deletions src/gen_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void *render_thread(void * arg)
g_logger(G_LOG_LEVEL_DEBUG, "Starting render thread: %lu", (unsigned long) pthread_self());

for (iMaxConfigs = 0; iMaxConfigs < XMLCONFIGS_MAX; ++iMaxConfigs) {
if (parentxmlconfig[iMaxConfigs].xmlname[0] == 0 || parentxmlconfig[iMaxConfigs].xmlfile[0] == 0) {
if (parentxmlconfig[iMaxConfigs].xmlname == NULL || parentxmlconfig[iMaxConfigs].xmlfile == NULL) {
break;
}

Expand Down Expand Up @@ -405,7 +405,7 @@ void *render_thread(void * arg)
* up the mapnik datasources to support larger postgres connection pools
*/
if (parentxmlconfig[iMaxConfigs].num_threads > 10) {
g_logger(G_LOG_LEVEL_INFO, "Updating max_connection parameter for mapnik layers to reflect thread count");
g_logger(G_LOG_LEVEL_DEBUG, "Updating max_connection parameter for mapnik layers to reflect thread count");
parameterize_map_max_connections(maps[iMaxConfigs].map, parentxmlconfig[iMaxConfigs].num_threads);
}

Expand All @@ -428,7 +428,7 @@ void *render_thread(void * arg)
maps[iMaxConfigs].htcphost);

if (maps[iMaxConfigs].htcpsock > 0) {
g_logger(G_LOG_LEVEL_INFO, "Successfully opened socket for HTCP cache expiry");
g_logger(G_LOG_LEVEL_DEBUG, "Successfully opened socket for HTCP cache expiry");
} else {
g_logger(G_LOG_LEVEL_ERROR, "Failed to open socket for HTCP cache expiry");
}
Expand Down
4 changes: 2 additions & 2 deletions src/parameterize_style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ parameterize_function_ptr init_parameterization_function(char * function_name)
g_logger(G_LOG_LEVEL_DEBUG, "Parameterize_style not specified (or empty string specified)");
return NULL;
} else if (strcmp(function_name, "language") == 0) {
g_logger(G_LOG_LEVEL_INFO, "Loading parameterization function for %s", function_name);
g_logger(G_LOG_LEVEL_DEBUG, "Loading parameterization function for '%s'", function_name);
return parameterize_map_language;
} else {
g_logger(G_LOG_LEVEL_WARNING, "unknown parameterization function for %s", function_name);
g_logger(G_LOG_LEVEL_WARNING, "unknown parameterization function for '%s'", function_name);
}

return NULL;
Expand Down
Loading

0 comments on commit 1c9f8b6

Please sign in to comment.