mirror of https://github.com/statping/statping
upgrades - plugins
parent
c7ff4ef9ef
commit
15c74bf4d2
41
main.go
41
main.go
|
@ -89,27 +89,28 @@ func LoadPlugins() {
|
||||||
if len(ext) != 2 {
|
if len(ext) != 2 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if ext[1] == "so" {
|
if ext[1] != "so" {
|
||||||
plug, err := plg.Open("plugins/"+f.Name())
|
continue
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Plugin '%v' could not load correctly.\n", f.Name())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
symPlugin, err := plug.Lookup("Plugin")
|
|
||||||
var plugActions plugin.PluginActions
|
|
||||||
plugActions, ok := symPlugin.(plugin.PluginActions)
|
|
||||||
if !ok {
|
|
||||||
fmt.Printf("Plugin '%v' could not load correctly, error: %v\n", f.Name(), "unexpected type from module symbol")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
//plugin := plugActions.Plugin()
|
|
||||||
//
|
|
||||||
//fmt.Println(plugin.OnLoad)
|
|
||||||
|
|
||||||
plugActions.OnLoad()
|
|
||||||
|
|
||||||
allPlugins = append(allPlugins, plugActions.Plugin())
|
|
||||||
}
|
}
|
||||||
|
plug, err := plg.Open("plugins/" + f.Name())
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Plugin '%v' could not load correctly.\n", f.Name())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
symPlugin, err := plug.Lookup("Plugin")
|
||||||
|
var plugActions plugin.PluginActions
|
||||||
|
plugActions, ok := symPlugin.(plugin.PluginActions)
|
||||||
|
if !ok {
|
||||||
|
fmt.Printf("Plugin '%v' could not load correctly, error: %v\n", f.Name(), "unexpected type from module symbol")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
//plugin := plugActions.Plugin()
|
||||||
|
//
|
||||||
|
//fmt.Println(plugin.OnLoad)
|
||||||
|
|
||||||
|
plugActions.OnLoad()
|
||||||
|
|
||||||
|
//allPlugins = append(allPlugins, plugActions.Plugin())
|
||||||
}
|
}
|
||||||
core.Plugins = allPlugins
|
core.Plugins = allPlugins
|
||||||
fmt.Printf("Loaded %v Plugins\n", len(allPlugins))
|
fmt.Printf("Loaded %v Plugins\n", len(allPlugins))
|
||||||
|
|
|
@ -26,7 +26,7 @@ type Routing struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PluginActions interface {
|
type PluginActions interface {
|
||||||
Plugin() *PluginInfo
|
//Plugin() *PluginInfo
|
||||||
SaveForm()
|
SaveForm()
|
||||||
OnInstall()
|
OnInstall()
|
||||||
OnUninstall()
|
OnUninstall()
|
||||||
|
@ -34,8 +34,11 @@ type PluginActions interface {
|
||||||
OnHit()
|
OnHit()
|
||||||
OnSettingsSaved()
|
OnSettingsSaved()
|
||||||
OnNewUser()
|
OnNewUser()
|
||||||
|
OnNewService()
|
||||||
OnShutdown()
|
OnShutdown()
|
||||||
OnLoad()
|
OnLoad()
|
||||||
|
OnBeforeRequest()
|
||||||
|
OnAfterRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetDatabase(db *sql.DB) {
|
func SetDatabase(db *sql.DB) {
|
||||||
|
|
BIN
plugins/slack.so
BIN
plugins/slack.so
Binary file not shown.
Loading…
Reference in New Issue