mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-12 23:14:36 +01:00
add option to disable soft-crashing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"host_ip": "127.0.0.1",
|
||||
"bin_path": "bin",
|
||||
"DisableSoftCrash": false,
|
||||
"devmode": true,
|
||||
"devmodeoptions": {
|
||||
"serverName" : "",
|
||||
|
||||
@@ -9,9 +9,10 @@ import (
|
||||
|
||||
// Config holds the global server-wide config.
|
||||
type Config struct {
|
||||
HostIP string `mapstructure:"host_ip"`
|
||||
BinPath string `mapstructure:"bin_path"`
|
||||
DevMode bool
|
||||
HostIP string `mapstructure:"host_ip"`
|
||||
BinPath string `mapstructure:"bin_path"`
|
||||
DisableSoftCrash bool
|
||||
DevMode bool
|
||||
|
||||
DevModeOptions DevModeOptions
|
||||
Discord Discord
|
||||
|
||||
8
main.go
8
main.go
@@ -19,6 +19,8 @@ import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var erupeConfig *config.Config
|
||||
|
||||
// Temporary DB auto clean on startup for quick development & testing.
|
||||
func cleanDB(db *sqlx.DB) {
|
||||
_ = db.MustExec("DELETE FROM guild_characters")
|
||||
@@ -29,6 +31,7 @@ func cleanDB(db *sqlx.DB) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
zapLogger, _ := zap.NewDevelopment()
|
||||
defer zapLogger.Sync()
|
||||
logger := zapLogger.Named("main")
|
||||
@@ -36,7 +39,7 @@ func main() {
|
||||
logger.Info("Starting Erupe")
|
||||
|
||||
// Load the configuration.
|
||||
erupeConfig, err := config.LoadConfig()
|
||||
erupeConfig, err = config.LoadConfig()
|
||||
if err != nil {
|
||||
preventClose(fmt.Sprintf("Failed to load config: %s", err.Error()))
|
||||
}
|
||||
@@ -209,6 +212,9 @@ func wait() {
|
||||
}
|
||||
|
||||
func preventClose(text string) {
|
||||
if erupeConfig.DisableSoftCrash {
|
||||
os.Exit(0)
|
||||
}
|
||||
fmt.Println("\nFailed to start Erupe:\n" + text)
|
||||
go wait()
|
||||
fmt.Println("\nPress Enter/Return to exit...")
|
||||
|
||||
Reference in New Issue
Block a user