Files
SugarDB/cmd/main.go
Kelvin Mwinuka 703ad2a802 Rename the project to SugarDB. (#130)
Renames project to "SugarDB" - @kelvinmwinuka
2024-09-22 21:31:12 +08:00

54 lines
1.3 KiB
Go

// Copyright 2024 Kelvin Clement Mwinuka
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"context"
"github.com/echovault/sugardb/internal"
"github.com/echovault/sugardb/internal/config"
"github.com/echovault/sugardb/sugardb"
"log"
"os"
"os/signal"
"syscall"
)
func main() {
conf, err := config.GetConfig()
if err != nil {
log.Fatal(err)
}
ctx := context.WithValue(context.Background(), internal.ContextServerID("ServerID"), conf.ServerID)
cancelCh := make(chan os.Signal, 1)
signal.Notify(cancelCh, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
server, err := sugardb.NewSugarDB(
sugardb.WithContext(ctx),
sugardb.WithConfig(conf),
)
if err != nil {
log.Fatal(err)
}
go server.Start()
<-cancelCh
server.ShutDown()
}