# Appointing a new Dgraph leader node

You can use the `appointNewDgraphLeader.sh` script to appoint a new Dgraph leader.

The use case for this script is when there is a long-running ingest in progress in the Dgraph HDFS Agent, and the Dgraph goes down for some reason. Instead of waiting until a new write request comes in, the administrator can just run this script to restart the ingest on another machine. (A file is maintained in HDFS that logs the exact progress of the ingest. The newly-appointed Dgraph HDFS Agent leader reads the file and knows at what point to pick up the ingest).

For example, the Dgraph HDFS Agent on Dgraph_A is performing an ingest when the Dgraph crashes (which results in the ingest being suspended). When the script is run, the new leader can be Dgraph_B, in which case the ingest is picked up at the point when it was stopped (except that Dgraph_B is now performing the ingest instead of Dgraph_A). Because there is only one index shared among the Dgraphs, the ingest can be resumed by the new leader.

Note that if the script is run but a new leader has been appointed in the interim, then the script basically reappoints the same leader.

The syntax for running the script is:

    ./appointNewDgraphLeader.sh <dg_address>

where dg_address is the FQDN (fully-qualified domain name) and port of the Dgraph Gateway server. For example:

    ./appointNewDgraphLeader.sh web009.us.example.com:7003

To appoint a new Dgraph leader:

1. Navigate to the $DGRAPH_HOME/dgraph-hdfs-agent/bin directory.
2. Run the `appointNewDgraphLeader.sh` script with the FQDN and port of the Dgraph Gateway, as in the example above.

If a new Dgraph leader is successfully appointed, the script returns this message:

    New Dgraph Leader appointed

An unsuccessful operation could return either of these messages:

    Unable to appoint new Dgraph leader

    Could not reach Dgraph gateway

Note that an unsuccessful attempt could be caused by an incorrect address.