Documentation
¶
Overview ¶
Copyright © 2020 MARLIN TEAM <info@marlin.pro>
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.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "marlinctl", Short: "Marlinctl provides a command line interface for setting up the different components of the Marlin network.", Long: `Marlinctl provides a command line interface for setting up the different components of the Marlin network. It can spawn up beacons, gateways, relays on various platforms and runtimes.`, Version: version.RootCmdVersion, Run: func(cmd *cobra.Command, args []string) { }, PersistentPreRun: func(cmd *cobra.Command, args []string) { lvl, err := log.ParseLevel(logLevel) if err != nil { log.Error("Invalid loglevel: ", logLevel) os.Exit(1) } log.SetLevel(lvl) err = readConfig() var configuredRegistries []types.Registry err = viper.UnmarshalKey("registries", &configuredRegistries) if err != nil { log.Error("Error reading registries from cfg file: ", err) os.Exit(1) } registry.SetupGlobalRegistry(configuredRegistries) currentTime := time.Now().Unix() lastSyncTime := viper.GetTime("last_registry_sync").Unix() if skipRegistrySync == false && (currentTime-lastSyncTime) > 15*60 || forcefulRegistrySync { err = registry.GlobalRegistry.Sync() if err != nil { log.Error("Error while syncing registry: " + err.Error()) os.Exit(1) } viper.Set("last_registry_sync", time.Now()) err := viper.WriteConfig() if err != nil { log.Error("Error while writing sync time to state: " + err.Error()) os.Exit(1) } } else { log.Debug("Skipping registry sync procedure. Metrics: curr: ", currentTime, " lst: ", lastSyncTime, " skip,force: ", skipRegistrySync, " ", forcefulRegistrySync) } if !skipMarlinctlUpdateCheck { hasUpgraded, err := checkMarlinctlUpdates() if err != nil { log.Error("Error while upgrading marlinctl: " + err.Error()) os.Exit(1) } if hasUpgraded { log.Info("Starting upgraded marlinctl") cmd := exec.Command(os.Args[0], os.Args[1:]...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr err = cmd.Start() if err != nil { fmt.Println("Unable to start updated cli. Retry running same command ", err) } err = cmd.Wait() if err != nil { fmt.Println("error occured: ", err) } os.Exit(2) } } else { log.Debug("Skipping marlinctl update check") } err = util.ChownRmarlinctlDir() if err != nil { log.Error("Error while chowning .marlin " + err.Error()) os.Exit(1) } }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.