Gracefully Stopping Iguana Daemon on Linux

Introduction

This tip is shows you how to safely shut down the Iguana service daemon using a terminal window, and also tells you what to avoid.

Task [top]

Shutdown the Iguana daemon safely according to our best practice.

Implementation [top]

To stop this daemon gracefully:

  1. Open a terminal window.
  2. Run this command:

    This command will perform a clean shutdown of Iguana and will allow Iguana to create a coredump if the are any issues.

    killall -SIGTERM iguana_service

  3. If and only if the daemon has hung (does not stop for SIGTERM) then you can force kill Iguana as a last resort:

    This kills the Iguana process immediately without allowing it to perform cleanup, also Iguana will not create a coredump. And it can leave various problems like, memory leaks, zombie processes, unclosed connections, etc.

    1. Run the kill-9 command:

      kill -9 <Iguana PID>

    2. If your Iguana does not restart correctly you will need to reboot the Server to clean up Iguana memory issues caused by the forced shutdown.

Note: The only recommended way to kill the Iguana daemon is by using the  SIGTERM signal option as it allows the processes to shutdown cleanly.

Using any other option (like kill -9) may result in improper Iguana shutdown.

 

How it works [top]

Gracefully (safely) stopping a process:

What does this actually mean? It means that you “politely” ask the process to stop which allows it to perform cleanup before closing. This means it will wait for external processes (like web services and databases) to return results before it will shut down. Unfortunately this also means that sometimes a process will freeze or “hang” if something goes wrong, for example waiting for a database connection (or web service) that never returns a result is common cause of a frozen process.

This is the recommended way to shut down a service or process.

Force stopping a process:

What does this actually mean? It means that you “rudely” force the process to stop and do not allow it to perform cleanup before closing. This means it will not wait for external processes (like web services and databases) to return results before it shuts down. Unfortunately because cleanup is not performed it can leave various “artifacts” like, unreclaimed memory (a so called memory leak), zombie processes (child processes not shutdown), unclosed connections, etc.

This method of shutting down a daemon or process should only be used as a last resort for frozen (“hung”) processes.

How the killall and kill commands work:

The ‘killall command kills all instances of a given process identified by the specified name (one or more processes can correspond to the given name). The kill command kills a single process identified by the specified process id. You should always use the SIGTERM signal option as it allows the processes to shutdown cleanly.

Shown below are some more common kill/killal signals:

Signal name Signal value Effect
SIGHUP 1 Hangup
SIGINT 2 Interrupt from keyboard
SIGKILL 9 Kill signal
SIGTERM 15 Termination signal
SIGSTOP 17,19,23 Stop the process

Warning: Only use kill -9 PID command (SIGKILL signal) as a last resort because it can result in improper shutdown. Force killing in this way is how we start running into problems with Iguana not shutting down properly.

If you do use ‘kill -9 PID’ and Iguana does not restart you may need to reboot the server (to clean up memory issues from incorrect Iguana shutdown).

More information [top]

Leave A Comment?