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:

    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:
    1. Run the kill-9 command:

      kill -9 <Iguana PID>

    2. This will kill the Iguana process (stop it immediately) without allowing it to perform cleanup.
    3. 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]

Windows has many ways that you can manage processes:

  • The Services Manager (GUI) application
  • The net stop and net start command — that you run in a command window
  • The taskkill command — that you run in a command window
  • The Task Manager (GUI) application
  • The Stop-Service command — that you run in a powershell window
  • The sysinternals Process Explorer (a free Microsoft utility)

All of these methods will allow you to stop a process gracefully. Most of them (other than the first two) also allow you to force stop a process or process tree.

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.

Note:

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?