mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: added modules
This commit is contained in:
33
core/cmd/root.go
Normal file
33
core/cmd/root.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
// Used for flags.
|
||||
cfgFile string
|
||||
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "crawlab",
|
||||
Short: "CLI tool for Crawlab",
|
||||
Long: `The CLI tool is for controlling against Crawlab.
|
||||
Crawlab is a distributed web crawler and task admin platform
|
||||
aimed at making web crawling and task management easier.
|
||||
`,
|
||||
}
|
||||
)
|
||||
|
||||
// Execute executes the root command.
|
||||
func Execute() error {
|
||||
return rootCmd.Execute()
|
||||
}
|
||||
|
||||
// GetRootCmd get rootCmd instance
|
||||
func GetRootCmd() *cobra.Command {
|
||||
return rootCmd
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "c", "", "Use Custom Config File")
|
||||
}
|
||||
25
core/cmd/server.go
Normal file
25
core/cmd/server.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/apps"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(serverCmd)
|
||||
}
|
||||
|
||||
var serverCmd = &cobra.Command{
|
||||
Use: "server",
|
||||
Aliases: []string{"s"},
|
||||
Short: "Start Crawlab server",
|
||||
Long: `Start Crawlab node server that can serve as API, task scheduler, task runner, etc.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// app
|
||||
//svr := apps.GetServer(opts...)
|
||||
svr := apps.GetServerV2()
|
||||
|
||||
// start
|
||||
apps.Start(svr)
|
||||
},
|
||||
}
|
||||
17
core/cmd/server_test.go
Normal file
17
core/cmd/server_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/apps"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCmdServer(t *testing.T) {
|
||||
_ = os.Setenv("CRAWLAB_PPROF", "true")
|
||||
|
||||
// app
|
||||
svr := apps.GetServerV2()
|
||||
|
||||
// start
|
||||
apps.Start(svr)
|
||||
}
|
||||
Reference in New Issue
Block a user