cmd

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2018 License: AGPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

Package cmd implements commands for running pydio services

Index

Constants

This section is empty.

Variables

View Source
var (
	FilterStartTags    []string
	FilterStartExclude []string
)
View Source
var (
	IsFork bool
)
View Source
var RootCmd = &cobra.Command{
	Use:   "pydio",
	Short: "Secure File Sharing for business",
	Long: `Thank you for using Pydio Cells !
Comprehensive sync & share solution for your collaborators. Open-source software deployed on-premise or in a private cloud.

INSTALL
=======
For the very first run, use './pydio install' to load browser-based or command-line based installation wizard. Services
will start at the end of the installation.

RUN
===
Run './pydio start' to load all services.

LOGS LEVEL
==========
By default, logs are outputted in console format at the Info level. You can set the PYDIO_LOGS_LEVEL environment variable
to one of the following values:
 - debug, info, error : logs are written in console format with the according level
 - production : logs are written in json format, for usage with a log aggregator tool.

SERVICES DISCOVERY
==================
Micro services need a registry mechanism to discover each other. By default, Pydio ships with Nats.io and Consul.io implementations.
You don't need to install any dependency. By default, Pydio uses the NATS implementation. You can switch to consul by using
the flag --registry=consul.

`,
	PreRun: func(cmd *cobra.Command, args []string) {},
	PersistentPreRun: func(cmd *cobra.Command, args []string) {

		if cmd == StartCmd {
			common.LogCaptureStdOut = true
		}

		handleSignals()

		for _, v := range common.ServicesDiscovery {
			if v != viper.Get("registry").(string) {
				FilterStartExclude = append(FilterStartExclude, v)
			}
		}

		registry.Default.Filter(func(s registry.Service) bool {
			for _, exclude := range FilterStartExclude {
				re := regexp.MustCompile(exclude)

				if strings.HasPrefix(s.Name(), exclude) || re.MatchString(s.Name()) {
					return true
				}
			}

			return false
		})

		initServices()

		if s, err := registry.Default.ListServices(); err != nil {
			cmd.Print("Could not retrieve list of services")
			os.Exit(0)
		} else {
			allServices = s
		}
	},
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

RootCmd represents the base command when called without any subcommands

View Source
var SslCmd = &cobra.Command{
	Use:   "ssl",
	Short: "Enable/Disable SSL support",
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}

SslCmd represents the ssl command

View Source
var SslModeCmd = &cobra.Command{
	Use:   "mode",
	Short: "Enable HTTPS on proxy",
	Long:  `Setup SSL on application main access point`,
	Run: func(cmd *cobra.Command, args []string) {

		enabled, e := promptSslMode()
		if e != nil {
			log.Fatal(e)
		}

		extUrl, _ := url.Parse(config.Get("defaults", "url").String(""))
		intUrl, _ := url.Parse(config.Get("defaults", "urlInternal").String(""))
		if enabled {
			extUrl.Scheme = "https"
			intUrl.Scheme = "https"
		} else {
			extUrl.Scheme = "http"
			intUrl.Scheme = "http"
		}
		config.Set(extUrl.String(), "defaults", "url")
		config.Set(intUrl.String(), "defaults", "urlInternal")
		utils.SaveConfigs()

		var frontWrite error
		if fConf, e := config.FrontBootstrapFromConfig(extUrl.String()); e == nil {
			root := config.Get("defaults", "frontRoot").String("")
			if root != "" {
				frontWrite = config.FrontWriteBootstrap(root, fConf)
				config.FrontClearCache(root)
			} else {
				frontWrite = fmt.Errorf("cannot find root for frontend")
			}
		} else {
			frontWrite = e
		}

		if frontWrite == nil {
			cmd.Println("*************************************************************")
			cmd.Println(" Please restart pydio now. Frontend config has been updated  ")
			cmd.Println("**************************************************************")
		} else {
			cmd.Println("*************************************************************")
			cmd.Println(" Please restart pydio now.")
			cmd.Println(" WARNING: Frontend Config was not updated, update it manually!")
			cmd.Println(" Error was  ", frontWrite.Error())
			cmd.Println("**************************************************************")
		}

	},
}

enableCmd represents the enable command

View Source
var StartCmd = &cobra.Command{
	Use:   "start",
	Short: "Start micro services",
	Long: `Start one or more services on this machine

SYNTAX
======
$ pydio start [flags] args...

Additional arguments are regexp that can match any of the service names available (see pydio list command).
The -t/--tags flag may limit to only a certain category of services, use lowercase like broker, idm, data, etc...
The -x/--exclude flag may exclude one or more services
Both flags may be used in cunjonction with the regexp arguments.

EXAMPLES
========
Start only services starting with grpc
$ pydio start pydio.grpc

Start only services for scheduler
$ pydio start --tag=scheduler

Start whole plateform except the roles service
$ pydio start --exclude=pydio.grpc.idm.roles

`,
	PreRun: func(cmd *cobra.Command, args []string) {

		registry.Default.Filter(func(s registry.Service) bool {
			re := regexp.MustCompile(common.SERVICE_INSTALL)

			if re.MatchString(s.Name()) {
				return true
			}

			return false
		})

		registry.Default.Filter(func(s registry.Service) bool {
			for _, t := range FilterStartTags {
				for _, st := range s.Tags() {
					if t == st {
						return false
					}
				}
			}

			return len(FilterStartTags) > 0
		})

		registry.Default.Filter(func(s registry.Service) bool {
			for _, arg := range args {
				reArg := regexp.MustCompile(arg)
				if reArg.MatchString(s.Name()) {
					return false
				}
				if s.MatchesRegexp(arg) {
					return false
				}
			}
			return len(args) > 0
		})

		registry.Default.Filter(func(s registry.Service) bool {
			if len(args) == 0 && s.Regexp() != nil {
				return true
			}
			return false
		})

		if s, err := registry.Default.ListServices(); err != nil {
			cmd.Print("Could not retrieve list of services")
			os.Exit(0)
		} else {
			allServices = s
		}

	},

	Run: func(cmd *cobra.Command, args []string) {

		for _, service := range allServices {
			go service.Start()
		}

		wg.Add(1)
		wg.Wait()
	},
}

StartCmd represents the start command

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

type Tags

type Tags struct {
	Name     string
	Services map[string]registry.Service
	Tags     map[string]*Tags
}

Directories

Path Synopsis
Package benchmark is the main package for performing benchmarking requests
Package benchmark is the main package for performing benchmarking requests
cmd
Package cmd implements commands for the benchmark command line tool
Package cmd implements commands for the benchmark command line tool
cmd/testsgo
Package tests is a first draft for benchmarking.
Package tests is a first draft for benchmarking.
cmd/testsgo/dummysetup
Package dummysetup provides utilitary methods to set up a dummy environment for benchmarks.
Package dummysetup provides utilitary methods to set up a dummy environment for benchmarks.
cmd/testsgo/idmtest
Package idmtest performs benchmarks on Roles
Package idmtest performs benchmarks on Roles
ctl
Package cli is the pydio control client for performing grpc requests on running services
Package cli is the pydio control client for performing grpc requests on running services
cmd
Package cmd implements all commands for pydio control client
Package cmd implements all commands for pydio control client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL