mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-03 19:56:22 -07:00
Add a few more event triggers, to be triggered only once
This commit is contained in:
parent
ae7350e1c5
commit
761074d6b2
2 changed files with 19 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"syscall"
|
||||
|
||||
"github.com/gochan-org/gochan/pkg/config"
|
||||
"github.com/gochan-org/gochan/pkg/events"
|
||||
|
||||
"github.com/gochan-org/gochan/pkg/gcutil"
|
||||
|
||||
|
@ -45,6 +46,9 @@ func main() {
|
|||
gcutil.LogFatal().Err(err).Msg("failed loading plugins")
|
||||
}
|
||||
|
||||
events.TriggerEvent("startup")
|
||||
defer events.TriggerEvent("shutdown")
|
||||
|
||||
if err = gcsql.ConnectToDB(
|
||||
systemCritical.DBhost, systemCritical.DBtype, systemCritical.DBname,
|
||||
systemCritical.DBusername, systemCritical.DBpassword, systemCritical.DBprefix,
|
||||
|
@ -52,11 +56,13 @@ func main() {
|
|||
fmt.Println("Failed to connect to the database:", err.Error())
|
||||
gcutil.LogFatal().Err(err).Msg("Failed to connect to the database")
|
||||
}
|
||||
events.TriggerEvent("db-connected")
|
||||
fmt.Println("Connected to database")
|
||||
if err = gcsql.CheckAndInitializeDatabase(systemCritical.DBtype); err != nil {
|
||||
fmt.Println("Failed to initialize the database:", err.Error())
|
||||
gcutil.LogFatal().Err(err).Msg("Failed to initialize the database")
|
||||
}
|
||||
events.TriggerEvent("db-initialized")
|
||||
parseCommandLine()
|
||||
serverutil.InitMinifier()
|
||||
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
# Events
|
||||
This is a list of events that gochan may trigger at some point, that can be used in the plugin system.
|
||||
|
||||
- **db-connected**
|
||||
- Triggered after gochan successfully connects to the database but before it is checked and initialized (db version checking, provisisioning, etc)
|
||||
|
||||
- **db-initialized**
|
||||
- Triggered after the database is successfully initialized (db version checking, provisioning, etc)
|
||||
|
||||
- **incoming-upload**
|
||||
- Triggered by the `gcsql` package when an upload is attached to a post. It is triggered before the upload is entered in the database
|
||||
|
||||
- **shutdown**
|
||||
- Triggered when gochan is about to shut down, in `main()` as a deferred call
|
||||
|
||||
- **startup**
|
||||
- Triggered when gochan first starts after its plugin system is initialized. This is (or at least should be) only triggered once.
|
||||
|
||||
- **upload-saved**
|
||||
- Triggered by the `posting` package when an upload is saved to the disk but before thumbnails are generated.
|
Loading…
Add table
Add a link
Reference in a new issue