Skip to content

Commit

Permalink
feat: separate service command into rollapp specific services
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs committed Aug 12, 2024
1 parent 817dc50 commit 3a8c36f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 2 additions & 0 deletions cmd/rollapp/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/dymensionxyz/roller/cmd/rollapp/run"
"github.com/dymensionxyz/roller/cmd/rollapp/start"
"github.com/dymensionxyz/roller/cmd/rollapp/status"
loadservices "github.com/dymensionxyz/roller/cmd/services/load"
)

func Cmd() *cobra.Command {
Expand All @@ -21,6 +22,7 @@ func Cmd() *cobra.Command {
cmd.AddCommand(start.Cmd())
cmd.AddCommand(config.Cmd())
cmd.AddCommand(run.Cmd())
cmd.AddCommand(loadservices.RollappCmd())

return cmd
}
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/dymensionxyz/roller/cmd/relayer"
"github.com/dymensionxyz/roller/cmd/rollapp"
"github.com/dymensionxyz/roller/cmd/run"
"github.com/dymensionxyz/roller/cmd/services"
"github.com/dymensionxyz/roller/cmd/tx"
"github.com/dymensionxyz/roller/cmd/utils"
"github.com/dymensionxyz/roller/cmd/version"
Expand Down Expand Up @@ -41,7 +40,7 @@ func init() {
rootCmd.AddCommand(relayer.Cmd())
rootCmd.AddCommand(keys.Cmd())
rootCmd.AddCommand(run.Cmd())
rootCmd.AddCommand(services.Cmd())
// rootCmd.AddCommand(services.Cmd())
rootCmd.AddCommand(migrate.Cmd())
rootCmd.AddCommand(tx.Cmd())
rootCmd.AddCommand(test())
Expand Down
18 changes: 11 additions & 7 deletions cmd/services/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package load

import (
"bytes"
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"runtime"
"text/template"

"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/consts"
Expand All @@ -28,17 +28,21 @@ type ServiceTemplateData struct {
UserName string
}

func Cmd() *cobra.Command {
func RollappCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "load",
Short: "Loads the different rollapp services on the local machine",
Run: func(cmd *cobra.Command, args []string) {
if runtime.GOOS != "linux" {
errorhandling.PrettifyErrorIfExists(
errors.New("the services commands are only available on linux machines"),
pterm.Error.Printf(
"the %s commands are only available on linux machines",
pterm.DefaultBasicText.WithStyle(pterm.FgYellow.ToStyle()).
Sprintf("'services'"),
)

return
}
for _, service := range []string{"rollapp", "da-light-client", "relayer"} {
for _, service := range []string{"rollapp", "da"} {
serviceData := ServiceTemplateData{
Name: service,
ExecPath: consts.Executables.Roller,
Expand All @@ -53,8 +57,8 @@ func Cmd() *cobra.Command {
exec.Command("sudo", "systemctl", "daemon-reload"),
)
errorhandling.PrettifyErrorIfExists(err)
fmt.Println(
"💈 Services 'sequencer', 'da-light-client' and 'relayer' been loaded successfully.",
pterm.Success.Println(
"💈 Services 'sequencer', 'da-light-client' been loaded successfully.",
// " To start them, use 'systemctl start <service>'.",
)
},
Expand Down
22 changes: 8 additions & 14 deletions cmd/services/services.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package services

import (
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/services/load"
)

func Cmd() *cobra.Command {
cmd := &cobra.Command{
Use: "services",
Short: "Commands for managing the rollapp services.",
}
cmd.AddCommand(load.Cmd())
return cmd
}
// func Cmd() *cobra.Command {
// cmd := &cobra.Command{
// Use: "services",
// Short: "Commands for managing the rollapp services.",
// }
// // cmd.AddCommand(load.Cmd())
// return cmd
// }

0 comments on commit 3a8c36f

Please sign in to comment.