PostgreSQL Source Code  git master
pidfile.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pidfile.h
4  * Declarations describing the data directory lock file (postmaster.pid)
5  *
6  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/utils/pidfile.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef UTILS_PIDFILE_H
14 #define UTILS_PIDFILE_H
15 
16 /*
17  * As of Postgres 10, the contents of the data-directory lock file are:
18  *
19  * line #
20  * 1 postmaster PID (or negative of a standalone backend's PID)
21  * 2 data directory path
22  * 3 postmaster start timestamp (time_t representation)
23  * 4 port number
24  * 5 first Unix socket directory path (empty if none)
25  * 6 first listen_address (IP address or "*"; empty if no TCP port)
26  * 7 shared memory key (empty on Windows)
27  * 8 postmaster status (see values below)
28  *
29  * Lines 6 and up are added via AddToDataDirLockFile() after initial file
30  * creation; also, line 5 is initially empty and is changed after the first
31  * Unix socket is opened. Onlookers should not assume that lines 4 and up
32  * are filled in any particular order.
33  *
34  * Socket lock file(s), if used, have the same contents as lines 1-5, with
35  * line 5 being their own directory.
36  */
37 #define LOCK_FILE_LINE_PID 1
38 #define LOCK_FILE_LINE_DATA_DIR 2
39 #define LOCK_FILE_LINE_START_TIME 3
40 #define LOCK_FILE_LINE_PORT 4
41 #define LOCK_FILE_LINE_SOCKET_DIR 5
42 #define LOCK_FILE_LINE_LISTEN_ADDR 6
43 #define LOCK_FILE_LINE_SHMEM_KEY 7
44 #define LOCK_FILE_LINE_PM_STATUS 8
45 
46 /*
47  * The PM_STATUS line may contain one of these values. All these strings
48  * must be the same length, per comments for AddToDataDirLockFile().
49  * We pad with spaces as needed to make that true.
50  */
51 #define PM_STATUS_STARTING "starting" /* still starting up */
52 #define PM_STATUS_STOPPING "stopping" /* in shutdown sequence */
53 #define PM_STATUS_READY "ready " /* ready for connections */
54 #define PM_STATUS_STANDBY "standby " /* up, won't accept connections */
55 
56 #endif /* UTILS_PIDFILE_H */