repmgr node service

repmgr node service

show or execute the system service command to stop/start/restart/reload/promote a node

## Description

Shows or executes the system service command to stop/start/restart/reload a node.

This command is mainly meant for internal &repmgr; usage, but is useful for confirming the command configuration.

## Options

`--dry-run`

- Log the steps which would be taken, including displaying the command which would be executed.

`--action`

- The action to perform. One of `start`, `stop`, `restart`, `reload` or `promote`.

  If the parameter `--list-actions` is provided together with `--action`, the command which would be executed will be printed.

`--list-actions`

- List all configured commands.

  If the parameter `--action` is provided together with `--list-actions`, the command which would be executed for that particular action will be printed.

`--checkpoint`

- Issue a `CHECKPOINT` before stopping or restarting the node.

  Note that a superuser connection is required to be able to execute the `CHECKPOINT` command. From PostgreSQL 15 the `pg_checkpoint` predefined role removes the need for superuser permissions to perform `CHECKPOINT` command.

`-S`/`--superuser`

- Connect as the named superuser instead of the normal &repmgr; user.

## Exit codes

One of the following exit codes will be emitted by `repmgr node service`:

`SUCCESS (0)`

- No issues were detected.

`ERR_LOCAL_COMMAND (5)`

- Execution of the system service command failed.

## Examples

See what action would be taken for a restart:

    [postgres@node1 ~]$ repmgr -f /etc/repmgr/12/repmgr.conf node service --action=restart --checkpoint --dry-run
    INFO: a CHECKPOINT would be issued here
    INFO: would execute server command "sudo service postgresql-12 restart"

Restart the PostgreSQL instance:

    [postgres@node1 ~]$ repmgr -f /etc/repmgr/12/repmgr.conf node service --action=restart --checkpoint
    NOTICE: issuing CHECKPOINT
    DETAIL: executing server command "sudo service postgresql-12 restart"
    Redirecting to /bin/systemctl restart postgresql-12.service

List all commands:

    [postgres@node1 ~]$ repmgr -f /etc/repmgr/12/repmgr.conf node service --list-actions
    Following commands would be executed for each action:

        start: "sudo service postgresql-12 start"
         stop: "sudo service postgresql-12 stop"
      restart: "sudo service postgresql-12 restart"
       reload: "sudo service postgresql-12 reload"
      promote: "/usr/pgsql-12/bin/pg_ctl  -w -D '/var/lib/pgsql/12/data' promote"

List a single command:

    [postgres@node1 ~]$ repmgr -f /etc/repmgr/12/repmgr.conf node service --list-actions --action=promote
    /usr/pgsql-12/bin/pg_ctl  -w -D '/var/lib/pgsql/12/data' promote