If the previuos socket files exist, pgpool startup fails due to bind() failire.
This commit is to remove socket files at startup if PID file doesn't exist.
Also, I found some messages are effectively ignorede because log system is not yet initialized at start point.
I changed them to standard fprintf(stderr...).
{
if (kill(pid, 0) == 0)
{
- ereport(FATAL,
- (errmsg("pid file found. is another pgpool(%d) is running?\n", pid)));
+ fprintf(stderr, "ERROR: pid file found. is another pgpool(%d) is running?\n", pid);
+ exit(EXIT_FAILURE);
}
else
- ereport(NOTICE,
- (errmsg("pid file found but it seems bogus. Trying to start pgpool anyway...\n")));
+ fprintf(stderr, "NOTICE: pid file found but it seems bogus. Trying to start pgpool anyway...\n");
}
}
int status;
int len;
+ /* Delete any pre-existing socket file to avoid failure at bind() time */
+ unlink(un_addr_tmp.sun_path);
+
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1)
{