Method: Syndi::Bot#terminate

Defined in:
lib/syndi/bot.rb

#terminate(reason = 'Terminating') ⇒ Object

Terminate the bot.

Parameters:

  • reason (String) (defaults to: 'Terminating')

    The reason for termination.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/syndi/bot.rb', line 139

def terminate reason = 'Terminating'
  info "Syndi is terminating owing to thus: #{reason}"

  # Call :die
  @events.call :die, reason

  # Close the database.
  @db.disconnect

  # When dying, allow about three seconds for hooks to execute before
  # fully terminating.
  sleep 3

  # Delete syndi.pid
  File.delete 'syndi.pid' unless @opts.foreground?

  exit 0
end