2020-05-26 06:51:06 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-09-18 01:32:38 +00:00
|
|
|
"os"
|
|
|
|
"runtime/debug"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
2020-05-26 06:51:06 +00:00
|
|
|
"github.com/diamondburned/cchat-gtk/internal/gts"
|
|
|
|
"github.com/diamondburned/cchat-gtk/internal/log"
|
|
|
|
"github.com/diamondburned/cchat-gtk/internal/ui"
|
2020-06-20 06:55:39 +00:00
|
|
|
"github.com/diamondburned/cchat-gtk/internal/ui/config"
|
2020-05-26 06:51:06 +00:00
|
|
|
"github.com/diamondburned/cchat/services"
|
|
|
|
|
2020-06-17 07:06:34 +00:00
|
|
|
_ "github.com/diamondburned/cchat-discord"
|
2020-05-26 06:51:06 +00:00
|
|
|
_ "github.com/diamondburned/cchat-mock"
|
|
|
|
)
|
|
|
|
|
2020-06-20 07:28:47 +00:00
|
|
|
// destructor is used for debugging and profiling.
|
2020-06-17 07:06:34 +00:00
|
|
|
var destructor = func() {}
|
|
|
|
|
2020-09-18 01:32:38 +00:00
|
|
|
func init() {
|
|
|
|
// Aggressive memory freeing you asked, so aggressive memory freeing we will
|
|
|
|
// deliver.
|
|
|
|
if strings.Contains(os.Getenv("GODEBUG"), "madvdontneed=1") {
|
|
|
|
go func() {
|
|
|
|
log.Println("Now attempting to free memory every 5s... (madvdontneed=1)")
|
|
|
|
for range time.Tick(5 * time.Second) {
|
|
|
|
debug.FreeOSMemory()
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-26 06:51:06 +00:00
|
|
|
func main() {
|
2020-08-28 07:16:03 +00:00
|
|
|
gts.Main(func() gts.MainApplication {
|
2020-05-26 06:51:06 +00:00
|
|
|
var app = ui.NewApplication()
|
|
|
|
|
|
|
|
// Load all cchat services.
|
|
|
|
srvcs, errs := services.Get()
|
|
|
|
if len(errs) > 0 {
|
|
|
|
for _, err := range errs {
|
|
|
|
log.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the services.
|
|
|
|
for _, srvc := range srvcs {
|
|
|
|
app.AddService(srvc)
|
|
|
|
}
|
|
|
|
|
2020-06-20 06:55:39 +00:00
|
|
|
// Restore the configs.
|
2020-09-02 07:11:48 +00:00
|
|
|
config.Restore()
|
2020-06-20 06:55:39 +00:00
|
|
|
|
2020-05-26 06:51:06 +00:00
|
|
|
return app
|
|
|
|
})
|
2020-06-17 07:06:34 +00:00
|
|
|
|
|
|
|
destructor()
|
2020-05-26 06:51:06 +00:00
|
|
|
}
|