Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add start-all command #498

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Download the latest binary from the [Releases page](https://github.com/dagu-dev/

### <a name='LaunchtheWebUI'></a>1. Launch the Web UI

Start the server with the command `dagu server` and browse to `http://127.0.0.1:8080` to explore the Web UI.
Start the server and scheduler with the command `dagu start-all` and browse to `http://127.0.0.1:8080` to explore the Web UI.

### <a name='CreateaNewDAG'></a>2. Create a New DAG

Expand Down Expand Up @@ -236,11 +236,14 @@ dagu restart <file>
# Dry-runs the DAG
dagu dry [--params=<params>] <file>

# Launches both the web UI server and scheduler process
dagu start-all [--host=<host>] [--port=<port>] [--dags=<path to directory>]

# Launches the Dagu web UI server
dagu server
dagu server [--host=<host>] [--port=<port>] [--dags=<path to directory>]

# Starts the scheduler process
dagu scheduler
dagu scheduler [--dags=<path to directory>]

# Shows the current binary version
dagu version
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ func registerCommands(root *cobra.Command) {
rootCmd.AddCommand(serverCmd())
rootCmd.AddCommand(createSchedulerCommand())
rootCmd.AddCommand(retryCmd())
rootCmd.AddCommand(startAllCmd())
}
1 change: 0 additions & 1 deletion cmd/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func createSchedulerCommand() *cobra.Command {
Short: "Start the scheduler",
Long: `dagu scheduler [--dags=<DAGs dir>]`,
Run: func(cmd *cobra.Command, args []string) {
// TODO: fixme
config.Get().DAGs = getFlagString(cmd, "dags", config.Get().DAGs)

err := core.NewScheduler(app.TopLevelModule).Start(cmd.Context())
Expand Down
46 changes: 46 additions & 0 deletions cmd/start_all.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package cmd

import (
"log"

"github.com/dagu-dev/dagu/app"
"github.com/dagu-dev/dagu/internal/config"
"github.com/dagu-dev/dagu/service/core"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func startAllCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "start-all",
Short: "Launches both the Dagu web UI server and the scheduler process.",
Long: `dagu start-all [--dags=<DAGs dir>] [--host=<host>] [--port=<port>]`,
Run: func(cmd *cobra.Command, args []string) {
ctx := cmd.Context()

go func() {
config.Get().DAGs = getFlagString(cmd, "dags", config.Get().DAGs)
err := core.NewScheduler(app.TopLevelModule).Start(cmd.Context())
if err != nil {
log.Fatal(err)
}
}()

service := app.NewFrontendService()
err := service.Start(ctx)
checkError(err)
},
}
bindStartAllCommandFlags(cmd)
return cmd
}

func bindStartAllCommandFlags(cmd *cobra.Command) {
cmd.Flags().StringP("dags", "d", "", "location of DAG files (default is $HOME/.dagu/dags)")
cmd.Flags().StringP("host", "s", "", "server host (default is localhost)")
cmd.Flags().StringP("port", "p", "", "server port (default is 8080)")

_ = viper.BindPFlag("port", cmd.Flags().Lookup("port"))
_ = viper.BindPFlag("host", cmd.Flags().Lookup("host"))
_ = viper.BindPFlag("dags", cmd.Flags().Lookup("dags"))
}
40 changes: 31 additions & 9 deletions docs/source/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@ Command Line Interface

The following commands are available for interacting with Dagu:

- ``dagu start [--params=<params>] <file>``: Runs the DAG.
- ``dagu status <file>``: Displays the current status of the DAG.
- ``dagu retry --req=<request-id> <file>``: Re-runs the specified DAG run.
- ``dagu stop <file>``: Stops the DAG execution by sending TERM signals.
- ``dagu restart <file>``: Restarts the current running DAG.
- ``dagu dry [--params=<params>] <file>``: Dry-runs the DAG.
- ``dagu server``: Launches the Dagu web UI server.
- ``dagu scheduler``: Starts the scheduler process.
- ``dagu version``: Shows the current binary version.
.. code-block:: sh

# Runs the DAG
dagu start [--params=<params>] <file>

# Displays the current status of the DAG
dagu status <file>

# Re-runs the specified DAG run
dagu retry --req=<request-id> <file>

# Stops the DAG execution
dagu stop <file>

# Restarts the current running DAG
dagu restart <file>

# Dry-runs the DAG
dagu dry [--params=<params>] <file>

# Launches both the web UI server and scheduler process
dagu start-all [--host=<host>] [--port=<port>] [--dags=<path to directory>]

# Launches the Dagu web UI server
dagu server [--host=<host>] [--port=<port>] [--dags=<path to directory>]

# Starts the scheduler process
dagu scheduler [--dags=<path to directory>]

# Shows the current binary version
dagu version