void start_postmaster(ClusterInfo *cluster, bool quiet) { char cmd[MAXPGPATH]; const char *bindir; const char *datadir; unsigned short port; bool exit_hook_registered = false; bindir = cluster->bindir; datadir = cluster->pgdata; port = cluster->port; if (!exit_hook_registered) { #ifdef HAVE_ATEXIT atexit(stop_postmaster_atexit); #else on_exit(stop_postmaster_on_exit); #endif exit_hook_registered = true; } /* * On Win32, we can't send both pg_upgrade output and pg_ctl output to the * same file because we get the error: "The process cannot access the file * because it is being used by another process." so we have to send all * other output to 'nul'. * * Using autovacuum=off disables cleanup vacuum and analyze, but freeze * vacuums can still happen, so we set autovacuum_freeze_max_age to its * maximum. We assume all datfrozenxid and relfrozen values are less than * a gap of 2000000000 from the current xid counter, so autovacuum will * not touch them. */ snprintf(cmd, sizeof(cmd), SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" " "-o \"-p %d -c autovacuum=off " "-c autovacuum_freeze_max_age=2000000000\" " "start >> \"%s\" 2>&1" SYSTEMQUOTE, bindir, #ifndef WIN32 log_opts.filename, datadir, port, log_opts.filename); #else DEVNULL, datadir, port, DEVNULL); #endif exec_prog(true, "%s", cmd); /* wait for the server to start properly */ if (test_server_conn(cluster, POSTMASTER_UPTIME) == false) pg_log(PG_FATAL, " Unable to start %s postmaster with the command: %s\nPerhaps pg_hba.conf was not set to \"trust\".", CLUSTER_NAME(cluster), cmd); if ((os_info.postmasterPID = get_postmaster_pid(datadir)) == 0) pg_log(PG_FATAL, " Unable to get postmaster pid\n"); os_info.running_cluster = cluster; }
void start_postmaster(ClusterInfo *cluster, bool quiet) { char cmd[MAXPGPATH]; const char *bindir; const char *datadir; unsigned short port; bindir = cluster->bindir; datadir = cluster->pgdata; port = cluster->port; /* * On Win32, we can't send both pg_upgrade output and pg_ctl output to the * same file because we get the error: "The process cannot access the file * because it is being used by another process." so we have to send all * other output to 'nul'. */ snprintf(cmd, sizeof(cmd), SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" " "-o \"-p %d -c autovacuum=off " "-c autovacuum_freeze_max_age=2000000000\" " "start >> \"%s\" 2>&1" SYSTEMQUOTE, bindir, #ifndef WIN32 log_opts.filename, datadir, port, log_opts.filename); #else DEVNULL, datadir, port, DEVNULL); #endif exec_prog(true, "%s", cmd); /* wait for the server to start properly */ if (test_server_conn(cluster, POSTMASTER_UPTIME) == false) pg_log(PG_FATAL, " Unable to start %s postmaster with the command: %s\nPerhaps pg_hba.conf was not set to \"trust\".", CLUSTER_NAME(cluster), cmd); if ((os_info.postmasterPID = get_postmaster_pid(datadir)) == 0) pg_log(PG_FATAL, " Unable to get postmaster pid\n"); os_info.running_cluster = cluster; }