/* * Entry point for worker loading */ void _PG_init(void) { BackgroundWorker worker; /* Add parameters */ kill_idle_load_params(); /* Worker parameter and registration */ MemSet(&worker, 0, sizeof(BackgroundWorker)); worker.bgw_flags = BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION; worker.bgw_start_time = BgWorkerStart_ConsistentState; worker.bgw_main = kill_idle_main; snprintf(worker.bgw_name, BGW_MAXLEN, "%s", worker_name); /* Wait 10 seconds for restart before crash */ worker.bgw_restart_time = 10; worker.bgw_main_arg = (Datum) 0; #if PG_VERSION_NUM >= 90400 /* * Notify PID is present since 9.4. If this is not initialized * a static background worker cannot start properly. */ worker.bgw_notify_pid = 0; #endif RegisterBackgroundWorker(&worker); }
/* * Entry point for worker loading */ void _PG_init(void) { BackgroundWorker worker; /* Add parameters */ kill_idle_load_params(); /* Worker parameter and registration */ worker.bgw_flags = BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION; worker.bgw_start_time = BgWorkerStart_ConsistentState; worker.bgw_main = kill_idle_main; snprintf(worker.bgw_name, BGW_MAXLEN, "%s", worker_name); /* Wait 10 seconds for restart before crash */ worker.bgw_restart_time = 10; worker.bgw_main_arg = (Datum) 0; RegisterBackgroundWorker(&worker); }