On Fri, 31 Oct 2008 13:51:35 +0100
Nicolas wrote:

>Ok, I will provide a patch for this (that will add a parameter
>'pid_file_name' to the config file).

see attach. i use this patch long time ago for execute more than one
instance of pgpool.

-- 
np: 
--- ./pool.h.orig	2007-11-26 11:09:41 +0300
+++ ./pool.h	2007-11-26 11:17:30 +0300
@@ -48,8 +48,11 @@
 /* HBA configuration file name */
 #define HBA_CONF_FILE_NAME "pool_hba.conf"
 
+/* log file directory */
+#define DEFAULT_LOGDIR "/var/log/pgpool"
+
 /* pid file directory */
-#define DEFAULT_LOGDIR "/tmp"
+#define DEFAULT_PIDDIR "/var/run/pgpool"
 
 /* Unix domain socket directory */
 #define DEFAULT_SOCKET_DIR "/tmp"
@@ -120,6 +123,7 @@ typedef struct {
     int	child_max_connections;	/* if max_connections received, child exits */
     int	max_pool;	/* max # of connection pool per child */
     char *logdir;		/* logging directory */
+    char *piddir;		/* pid file directory */
     char *backend_socket_dir;	/* Unix domain socket directory for the PostgreSQL server */
 	int replication_mode;		/* replication mode */
 	int replication_strict;	/* if non 0, wait for completion of the
--- ./pgpool.conf.sample.orig	2007-11-26 11:09:51 +0300
+++ ./pgpool.conf.sample	2007-11-26 11:20:22 +0300
@@ -44,7 +44,10 @@ connection_life_time = 0
 child_max_connections = 0
 
 # Logging directory
-logdir = '/tmp'
+logdir = '/var/log/pgpool'
+
+# Pid file directory
+piddir = '/var/run/pgpool'
 
 # Replication mode
 replication_mode = false
--- ./pool_process_query.c.orig	2007-11-26 11:10:24 +0300
+++ ./pool_process_query.c	2007-11-26 11:22:26 +0300
@@ -2588,6 +2588,11 @@ static void process_reporting(POOL_CONNE
 	snprintf(status[i].value, MAXVALLEN, "%s", pool_config->logdir);
 	strncpy(status[i].desc, "logging directory", MAXDESCLEN);
 	i++;
+	
+	strncpy(status[i].name, "piddir", POOLCONFIG_MAXNAMELEN);
+	snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->piddir);
+	strncpy(status[i].desc, "pid file directory", POOLCONFIG_MAXDESCLEN);
+	i++;
 
 	strncpy(status[i].name, "backend_socket_dir", MAXNAMELEN);
 	snprintf(status[i].value, MAXVALLEN, "%s", pool_config->backend_socket_dir);
--- ./pool_config.c.orig	2007-11-28 16:52:13 +0300
+++ ./pool_config.c	2007-11-28 16:57:57 +0300
@@ -1673,6 +1673,7 @@ int pool_init_config(void)
 	pool_config->child_max_connections = 0;
 	pool_config->authentication_timeout = 60;
 	pool_config->logdir = DEFAULT_LOGDIR;
+	pool_config->piddir = DEFAULT_PIDDIR;
  	pool_config->log_statement = 0;
 	pool_config->log_connections = 0;
 	pool_config->log_hostname = 0;
@@ -1991,6 +1992,24 @@ int pool_get_config(char *confpath, POOL
 			}
 			pool_config->logdir = str;
 		}
+		else if (!strcmp(key, "piddir") && CHECK_CONTEXT(INIT_CONFIG, context))
+		{
+			char *str;
+
+			if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+			{
+				PARSE_ERROR();
+				fclose(fd);
+				return(-1);
+			}
+			str = extract_string(yytext, token);
+			if (str == NULL)
+			{
+				fclose(fd);
+				return(-1);
+			}
+			pool_config->piddir = str;
+		}
        	else if (!strcmp(key, "log_connections") &&
 				 CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
 		{
--- ./pool_config.l.orig	2007-11-28 16:52:34 +0300
+++ ./pool_config.l	2007-11-28 17:00:38 +0300
@@ -135,6 +135,7 @@ int pool_init_config(void)
 	pool_config->child_max_connections = 0;
 	pool_config->authentication_timeout = 60;
 	pool_config->logdir = DEFAULT_LOGDIR;
+	pool_config->piddir = DEFAULT_PIDDIR;
  	pool_config->log_statement = 0;
 	pool_config->log_connections = 0;
 	pool_config->log_hostname = 0;
@@ -453,6 +454,24 @@ int pool_get_config(char *confpath, POOL
 			}
 			pool_config->logdir = str;
 		}
+		else if (!strcmp(key, "piddir") && CHECK_CONTEXT(INIT_CONFIG, context))
+		{
+			char *str;
+
+			if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+			{
+				PARSE_ERROR();
+				fclose(fd);
+				return(-1);
+			}
+			str = extract_string(yytext, token);
+			if (str == NULL)
+			{
+				fclose(fd);
+				return(-1);
+			}
+			pool_config->piddir = str;
+		}
        	else if (!strcmp(key, "log_connections") &&
 				 CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
 		{
--- main.c.orig	2008-03-12 08:06:37 +0300
+++ main.c	2008-03-27 16:29:51 +0300
@@ -699,7 +699,7 @@ static int read_pid_file(void)
 	char path[POOLMAXPATHLEN];
 	char pidbuf[128];
 
-	snprintf(path, sizeof(path), "%s/%s", pool_config->logdir, PID_FILE_NAME);
+	snprintf(path, sizeof(path), "%s/%s", pool_config->piddir, PID_FILE_NAME);
 	fd = fopen(path, "r");
 	if (!fd)
 	{
@@ -725,7 +725,7 @@ static void write_pid_file(void)
 	char path[POOLMAXPATHLEN];
 	char pidbuf[128];
 
-	snprintf(path, sizeof(path), "%s/%s", pool_config->logdir, PID_FILE_NAME);
+	snprintf(path, sizeof(path), "%s/%s", pool_config->piddir, PID_FILE_NAME);
 	fd = fopen(path, "w");
 	if (!fd)
 	{
@@ -948,7 +948,7 @@ static void myexit(int code)
 	
 	myunlink(un_addr.sun_path);
 	myunlink(pcp_un_addr.sun_path);
-	snprintf(path, sizeof(path), "%s/%s", pool_config->logdir, PID_FILE_NAME);
+	snprintf(path, sizeof(path), "%s/%s", pool_config->piddir, PID_FILE_NAME);
 	myunlink(path);
 
 	pool_shmem_exit(code);

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Pgpool-general mailing list
[email protected]
http://pgfoundry.org/mailman/listinfo/pgpool-general

Reply via email to