mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-28 17:50:56 +01:00
updated code structure
This commit is contained in:
@@ -10,12 +10,12 @@ func init() {
|
||||
}
|
||||
|
||||
var apiCmd = &cobra.Command{
|
||||
Use: "api",
|
||||
Short: "Start API server",
|
||||
Long: `Start API server of Crawlab which serves data to frontend`,
|
||||
Use: "api",
|
||||
Aliases: []string{"A"},
|
||||
Short: "Start API server",
|
||||
Long: `Start API server of Crawlab which serves data to frontend`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
api := apps.NewApi()
|
||||
api.Init()
|
||||
api.Run()
|
||||
apps.Start(api)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ func init() {
|
||||
}
|
||||
|
||||
var handlerCmd = &cobra.Command{
|
||||
Use: "handler",
|
||||
Short: "Start task handler",
|
||||
Long: `Start task handler service (worker) of Crawlab
|
||||
which runs tasks assigned by master node`,
|
||||
Use: "handler",
|
||||
Aliases: []string{"H"},
|
||||
Short: "Start handler",
|
||||
Long: `Start a handler instance of Crawlab
|
||||
which runs tasks with given parameters`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
handler := apps.NewHandler()
|
||||
handler.Init()
|
||||
handler.Run()
|
||||
apps.Start(handler)
|
||||
},
|
||||
}
|
||||
|
||||
22
backend/cmd/master.go
Normal file
22
backend/cmd/master.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"crawlab/apps"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(masterCmd)
|
||||
}
|
||||
|
||||
var masterCmd = &cobra.Command{
|
||||
Use: "master",
|
||||
Aliases: []string{"M"},
|
||||
Short: "Start master",
|
||||
Long: `Start a master instance of Crawlab
|
||||
which runs api and assign tasks to worker nodes`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
master := apps.NewMaster()
|
||||
apps.Start(master)
|
||||
},
|
||||
}
|
||||
23
backend/cmd/worker.go
Normal file
23
backend/cmd/worker.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"crawlab/apps"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(workerCmd)
|
||||
}
|
||||
|
||||
var workerCmd = &cobra.Command{
|
||||
Use: "worker",
|
||||
Aliases: []string{"W"},
|
||||
Short: "Start worker",
|
||||
Long: `Start a worker instance of Crawlab
|
||||
serving in the worker node and executes tasks
|
||||
assigned by the master node`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
worker := apps.NewWorker()
|
||||
apps.Start(worker)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user