How to programmatically check if aerospike process is running

The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.

How to programmatically check if aerospike process is running

Check if asd is running

Note, as shown in the examples below, always check return code, instead of parsing output from stdout of the given commands. The code check is more accurate and handles corner case scenarios.

Method 1: pidof

pidof asd
if [ $? -eq 0 ]; then
   echo "asd is running"
else
   echo "asd is not running"
fi

Method 2: systemctl

systemctl is-active aerospike
if [ $? -eq 0 ]; then
   echo "asd is running"
else
   echo "asd is not running"
fi

Check if aerospike stopped cleanly to find out if it will cold/fast re-start

If logging to file

tail -1 /var/log/aerospike/aerospike.log |grep "finished clean shutdown - exiting"
if [ $? -eq 0 ]; then
   echo "asd stopped cleanly"
else
   echo "asd did not stop cleanly"
fi

If logging using systemd

journalctl -u aerospike.service |tail -3 |grep "finished clean shutdown - exiting"
if [ $? -eq 0 ]; then
   echo "asd stopped cleanly"
else
   echo "asd did not stop cleanly"
fi

Refer to the Fast Restart and Cold Restart documentation pages for details on those restart modes.

Notes

For checking that a node has properly joined a cluster after starting, you can refer to the check_cluster_stable.sh script. This script can be used to check that migrations have completed as well for use cases requiring it. For further details, read the Aerospike Upgrade documentation page.

Keywords

SCRIPT CHECK CLUSTER STATUS ASD

Timestamp

6/26/2018

1 Like