pidfile.h 2.1 KB

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