MCPcopy
hub / github.com/daptin/daptin / Main

Function Main

server/server.go:81–632  ·  view source on GitHub ↗
(boxRoot http.FileSystem, db database.DatabaseConnection, localStoragePath string, olricDb *olric.EmbeddedClient, localOlricAddr string)

Source from the content-addressed store, hash-verified

79)
80
81func Main(boxRoot http.FileSystem, db database.DatabaseConnection, localStoragePath string, olricDb *olric.EmbeddedClient, localOlricAddr string) (
82 hostswitch.HostSwitch, *guerrilla.Daemon, task_scheduler.TaskScheduler, *resource.ConfigStore, *resource.CertificateManager,
83 *server2.FtpServer, *server.Server, *olric.EmbeddedClient) {
84
85 PrintCliBanner()
86
87 /// Start system initialise
88 log.Printf("Load config files")
89 initConfig, errs := LoadConfigFiles()
90 if errs != nil {
91 for _, err := range errs {
92 log.Errorf("Failed to load config indexFile: %v", err)
93 }
94 }
95
96 skipDbConfig, skipValueFound := os.LookupEnv("DAPTIN_SKIP_CONFIG_FROM_DATABASE")
97
98 var existingTables []table_info.TableInfo
99 if skipValueFound && skipDbConfig == "true" {
100 log.Printf("ENV[DAPTIN_SKIP_CONFIG_FROM_DATABASE] skip loading existing tables config from database")
101 } else {
102 log.Printf("ENV[DAPTIN_SKIP_CONFIG_FROM_DATABASE] loading existing tables config from database")
103 existingTables, _ = GetTablesFromWorld(db)
104 allTables := MergeTables(existingTables, initConfig.Tables)
105 initConfig.Tables = allTables
106 }
107
108 // rclone config load
109 //configfile.Install()
110 defaultConfig := fs.GetConfig(nil)
111 defaultConfig.DryRun = false
112 defaultConfig.LogLevel = fs.LogLevelDebug
113 defaultConfig.StatsLogLevel = fs.LogLevelDebug
114
115 skipResourceInitialise, ok := os.LookupEnv("DAPTIN_SKIP_INITIALISE_RESOURCES")
116 if ok && skipResourceInitialise == "true" {
117 log.Infof("Skipping db resource initialise: %v", skipResourceInitialise)
118 } else {
119 log.Infof("ENV[DAPTIN_SKIP_INITIALISE_RESOURCES] value: %v", skipResourceInitialise)
120 InitialiseServerResources(&initConfig, db)
121 }
122
123 configStore, err := resource.NewConfigStore(db)
124 resource.CheckErr(err, "Failed to get config store")
125 diskFileCache, err = lru.New(cacheSize)
126
127 transaction, err := db.Beginx()
128 if err != nil {
129 resource.CheckErr(err, "Failed to begin transaction [122]")
130 panic(err)
131 }
132
133 hostname, err := configStore.GetConfigValueFor("hostname", "backend", transaction)
134 if err != nil {
135 name, e := os.Hostname()
136 if e != nil {
137 name = "localhost"
138 }

Callers 2

createServerFunction · 0.92
mainFunction · 0.92

Calls 15

GetConfigValueForMethod · 0.95
SetConfigValueForMethod · 0.95
GetConfigIntValueForMethod · 0.95
SetConfigIntValueForMethod · 0.95
ListenMethod · 0.95
NewConfigStoreFunction · 0.92
CheckErrFunction · 0.92
NewAuthMiddlewareBuilderFunction · 0.92
InitJwtMiddlewareFunction · 0.92
NewCertificateManagerFunction · 0.92
NewTaskSchedulerFunction · 0.92

Tested by 1

createServerFunction · 0.74