Skip to content
Snippets Groups Projects
Verified Commit 60cbafb4 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: commit save point

parent 3f09dc49
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
<configuration default="false" name="server serve" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="conan" />
<working_directory value="$PROJECT_DIR$/development/examples/e1" />
<parameters value="--config=development/examples/e1/config.yaml server serve --pid-file=/tmp/conan.pid" />
<parameters value="--config=config.yaml server serve " />
<kind value="DIRECTORY" />
<directory value="$PROJECT_DIR$/application/source" />
<filePath value="$PROJECT_DIR$/application/source/main.go" />
......
......@@ -58,6 +58,7 @@ include $(MAKEFILE_IMPORT_PATH)target-deploy-tool.mk
#include $(MAKEFILE_IMPORT_PATH)target-docman.mk
#include $(MAKEFILE_IMPORT_PATH)target-node-build.mk
#include $(MAKEFILE_IMPORT_PATH)target-caddy.mk
include $(MAKEFILE_IMPORT_PATH)target-conan.mk
include $(MAKEFILE_IMPORT_PATH)target-update-makefiles.mk
include $(MAKEFILE_IMPORT_PATH)target-help.mk
include $(MAKEFILE_IMPORT_PATH)target-go-build.mk
......
......@@ -58,6 +58,7 @@ include $(MAKEFILE_IMPORT_PATH)terminal.mk
#include $(MAKEFILE_IMPORT_PATH)target-docman.mk
#include $(MAKEFILE_IMPORT_PATH)target-node-build.mk
#include $(MAKEFILE_IMPORT_PATH)target-caddy.mk
#include $(MAKEFILE_IMPORT_PATH)target-conan.mk
include $(MAKEFILE_IMPORT_PATH)target-update-makefiles.mk
include $(MAKEFILE_IMPORT_PATH)target-help.mk
#include $(MAKEFILE_IMPORT_PATH)target-go-build.mk
......
package command
import (
"fmt"
"gitlab.schukai.com/oss/utilities/conan/configuration"
"gitlab.schukai.com/oss/utilities/conan/logging"
"gitlab.schukai.com/oss/utilities/conan/server"
......@@ -25,8 +24,6 @@ func (r *ServerServeCommand) execute() {
configuration.SetServerAddress(r.Address)
configuration.SetServerWebPath(r.WebPath)
fmt.Printf("Serving on %s:%s\n", r.WatchPath, r.Exclude)
var w string
if r.WatchPath != "" {
w = r.WatchPath
......
......@@ -2,15 +2,6 @@ package configuration
type Settings map[string]interface{}
//type ClientAddress *Client
//type Client struct {
// Endpoints struct {
// Messages string `env:"CLIENT_ENDPOINT_MESSAGES,default=/messages" yaml:"Messages" json:"Messages"`
// } `yaml:"Endpoints" json:"Endpoints"`
// Settings `yaml:"Settings" json:"Settings"`
//}
type Watch struct {
Path string `yaml:"Path" json:"Path"`
Command string `yaml:"Command" json:"Command"`
......
......@@ -21,17 +21,6 @@ func GetServerLoglevel() string {
return configurationInstance.Server.Logging.Level
}
//
//func GetClientMessagesEndpointPath() string {
// u, err := url.ParseRequestURI(configurationInstance.Client.Endpoints.Messages)
// error2.CheckError(err)
// return u.Path
//}
//
//func GetClientMessagesEndpoint() string {
// return configurationInstance.Client.Endpoints.Messages
//}
func SetServerPort(port string) {
if port == "" {
......
......@@ -18,24 +18,8 @@ var configurationPath string
func init() {
configurationInstance = &ConfigStruct{}
// configurationInstance.Client = NewClient()
}
//func NewClient() Client {
// c := Client{}
// c.Settings = Settings{}
// return c
//}
func GetConfiguration() *ConfigStruct {
return configurationInstance
}
//func GetDefaultClientConfiguration() Client {
// return configurationInstance.Client
//}
func InitConfiguration(cfgPath, mnemonic string) {
userConfig := ""
......@@ -54,10 +38,18 @@ func InitConfiguration(cfgPath, mnemonic string) {
etcConfigPath := path.Join("/etc", mnemonic, constants.ConfigFileName)
if cfgPath != "" && !path.IsAbs(cfgPath) {
cfgPath = path.Join(current, cfgPath)
}
if cfgPath != "" {
if !path.IsAbs(cfgPath) {
cfgPath = path.Join(current, cfgPath)
}
if _, err := os.Stat(cfgPath); os.IsNotExist(err) {
error2.PrintErrorAndExit("Configuration file not found: " + cfgPath)
}
}
ctx := context.Background()
l := envconfig.PrefixLookuper(strings.ReplaceAll(strings.ToUpper(mnemonic), "-", "_")+"_", envconfig.OsLookuper())
......
......@@ -5,28 +5,6 @@ import (
"strconv"
)
func sanitizeMessageEndpoint() {
//e := configurationInstance.Client.Endpoints.Messages
//u, err := url.ParseRequestURI(e)
//error2.CheckError(err)
//
//if u.Scheme != "ws" {
// u.Scheme = "ws"
//}
//
//if u.Host == "" {
//
// u.Host = configurationInstance.Server.Host
// if u.Host == "" {
// error2.PrintErrorAndExit("Host not set")
// }
//}
//configurationInstance.Client.Endpoints.Messages = u.String()
}
func sanitizeSerer() {
if configurationInstance.Server.Address == "localhost" {
......@@ -63,5 +41,4 @@ func sanitizeWatch() {
func sanitize() {
sanitizeSerer()
sanitizeWatch()
//sanitizeMessageEndpoint()
}
......@@ -3,6 +3,7 @@ package logging
import (
"github.com/go-chi/chi/v5/middleware"
"gitlab.schukai.com/oss/utilities/conan/header"
"gitlab.schukai.com/oss/utilities/conan/release"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"net/http"
......@@ -14,15 +15,60 @@ var sugaredLogger *zap.SugaredLogger
func InitLogger() {
if logger != nil && sugaredLogger != nil {
return
var cfg zap.Config
if release.GetVersion() == "dev" {
cfg.Development = true
} else {
cfg.Development = false
}
var mode string
cfg.Encoding = "console"
cfg.OutputPaths = []string{"stdout"}
cfg.ErrorOutputPaths = []string{"stderr"}
cfg.EncoderConfig = zap.NewDevelopmentEncoderConfig()
l := zapcore.Level(10)
l = zap.InfoLevel
switch l {
// DebugLevel logs are typically voluminous, and are usually disabled in
// production.
case zap.DebugLevel:
cfg.Level = zap.NewAtomicLevelAt(zap.DebugLevel)
// InfoLevel is the default logging priority.
case zap.InfoLevel:
cfg.Level = zap.NewAtomicLevelAt(zap.InfoLevel)
// WarnLevel logs are more important than Info, but don't need individual
// human review.
case zap.WarnLevel:
cfg.Level = zap.NewAtomicLevelAt(zap.WarnLevel)
// ErrorLevel logs are high-priority. If an application is running smoothly,
// it shouldn't generate any error-level logs.
case zap.ErrorLevel:
cfg.Level = zap.NewAtomicLevelAt(zap.ErrorLevel)
// DPanicLevel logs are particularly important errors. In development the
// logger panics after writing the message.
case zap.DPanicLevel:
cfg.Level = zap.NewAtomicLevelAt(zap.DPanicLevel)
// PanicLevel logs a message, then panics.
case zap.PanicLevel:
cfg.Level = zap.NewAtomicLevelAt(zap.PanicLevel)
// FatalLevel logs a message, then calls os.Exit(1).
case zap.FatalLevel:
cfg.Level = zap.NewAtomicLevelAt(zap.FatalLevel)
default:
cfg.Level = zap.NewAtomicLevelAt(zap.ErrorLevel)
}
logger, _ = zap.NewDevelopment()
logger, err := cfg.Build()
if err != nil {
panic(err)
}
defer logger.Sync()
defer logger.Sync() // flushes buffer, if any
var mode string
sugaredLogger = logger.Sugar()
sugaredLogger.Infof("init %s logger", mode)
......
......@@ -67,7 +67,7 @@ func executeWatchAction(watchPath string) {
}
if w.Command == "" {
logging.LogInfo("watching: no command defined for %s", watchPath)
logging.LogDebug("watching: no command defined for %s", watchPath)
websocket.SendReloadMessage()
continue
}
......@@ -274,7 +274,7 @@ func addToWatchlist(p string) {
if err != nil {
logging.LogError("watching: watch error: %v", err.Error())
} else {
logging.LogInfo("watching: watching %s", p)
logging.LogDebug("watching: watching %s", p)
watchList[p] = p
}
......
File added
#############################################################################################
#############################################################################################
##
## SERVER CONAN
##
#############################################################################################
#############################################################################################
CONAN_BIN ?= $(VENDOR_PATH)conan
CONAN_CONFIG ?= $(VENDOR_PATH)conan.conf
$(CONAN_BIN):
$(QUIET) $(MKDIR) -p $(VENDOR_PATH)
$(QUIET) $(WGET) -O $(CONAN_BIN) http://download.schukai.com/tools/conan/conan-$(shell uname -s | tr [:upper:] [:lower:])-$(shell echo `uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/`)
$(QUIET) $(CHMOD) u+x $(CONAN_BIN)
.PHONY: run-conan
## run conan webserver
run-conan: $(CONAN_BIN)
$(QUIET) $(CONAN_BIN) server serve --config $(CONAN_CONFIG)
{"version":"0.1.38"}
{"version":"0.1.39"}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment