2014-04-26 09:18:56 +00:00
|
|
|
package ICCC
|
|
|
|
|
2014-10-19 17:19:11 +00:00
|
|
|
import (
|
|
|
|
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
|
|
|
|
"github.com/SommerEngineering/Ocean/Log"
|
|
|
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
|
|
|
"gopkg.in/mgo.v2/bson"
|
|
|
|
)
|
2014-04-26 09:18:56 +00:00
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Type to provide a shutdown function.
|
2014-04-26 09:18:56 +00:00
|
|
|
type ShutdownFunction struct {
|
|
|
|
}
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// The shutdown function for ICCC.
|
2014-04-26 09:18:56 +00:00
|
|
|
func (a ShutdownFunction) Shutdown() {
|
|
|
|
Log.LogShort(senderName, LM.CategoryAPP, LM.LevelWARN, LM.MessageNameSHUTDOWN, `Shutting down now all ICCC listener for this host.`)
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Define the database query:
|
2014-04-26 09:18:56 +00:00
|
|
|
selection := bson.D{{`IPAddressPort`, correctAddressWithPort}}
|
2015-06-17 15:44:52 +00:00
|
|
|
|
|
|
|
// Reserve the memory for an answer:
|
2014-04-26 09:18:56 +00:00
|
|
|
entry := Scheme.Listener{}
|
2015-06-17 15:44:52 +00:00
|
|
|
|
|
|
|
// Execute the query and iterate over the results:
|
2014-04-26 09:18:56 +00:00
|
|
|
iterator := collectionListener.Find(selection).Iter()
|
|
|
|
for iterator.Next(&entry) {
|
2015-06-17 15:44:52 +00:00
|
|
|
// Update the entry and set it to active=false:
|
2014-04-26 09:18:56 +00:00
|
|
|
selectionUpdate := bson.D{{`Channel`, entry.Channel}, {`Command`, entry.Command}, {`IPAddressPort`, correctAddressWithPort}}
|
|
|
|
entry.IsActive = false
|
2015-06-17 15:44:52 +00:00
|
|
|
|
|
|
|
// Update the entry:
|
2014-04-26 09:18:56 +00:00
|
|
|
collectionListener.Update(selectionUpdate, entry)
|
|
|
|
}
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Disconnect the database:
|
2014-06-04 19:41:18 +00:00
|
|
|
db.Logout()
|
|
|
|
dbSession.Close()
|
2015-07-10 12:36:47 +00:00
|
|
|
Log.LogShort(senderName, LM.CategoryAPP, LM.LevelWARN, LM.MessageNameSHUTDOWN, `Done shutting down all ICCC listener for this host.`)
|
2014-04-26 09:18:56 +00:00
|
|
|
}
|