Skip to content

Commit

Permalink
Rename opera to sonicd
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Kalina committed Feb 16, 2024
1 parent 58cabeb commit 5f84009
Show file tree
Hide file tree
Showing 36 changed files with 49 additions and 77 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
.PHONY: all
all: opera sonictool
all: sonicd sonictool

GOPROXY ?= "https://proxy.golang.org,direct"
.PHONY: opera
opera:
.PHONY: sonicd sonictool
sonicd:
GIT_COMMIT=`git rev-list -1 HEAD 2>/dev/null || echo ""` && \
GIT_DATE=`git log -1 --date=short --pretty=format:%ct 2>/dev/null || echo ""` && \
GOPROXY=$(GOPROXY) \
go build \
-ldflags "-s -w -X github.com/Fantom-foundation/go-opera/config.GitCommit=$${GIT_COMMIT} -X github.com/Fantom-foundation/go-opera/config.GitDate=$${GIT_DATE}" \
-o build/opera \
./cmd/opera
-o build/sonicd \
./cmd/sonicd

sonictool:
GIT_COMMIT=`git rev-list -1 HEAD 2>/dev/null || echo ""` && \
Expand All @@ -22,11 +22,11 @@ sonictool:
./cmd/sonictool

TAG ?= "latest"
.PHONY: opera-image
opera-image:
.PHONY: sonic-image
sonic-image:
docker build \
--network=host \
-f ./docker/Dockerfile.opera -t "opera:$(TAG)" .
-f ./docker/Dockerfile.opera -t "sonic:$(TAG)" .

.PHONY: test
test:
Expand Down
15 changes: 0 additions & 15 deletions cmd/opera/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/opera/launcher/accounts.go → cmd/sonicd/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package launcher
package main

import (
"fmt"
Expand Down
17 changes: 1 addition & 16 deletions cmdhelper/helpers.go → cmd/sonicd/cmdhelper/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
package cmdhelper

import (
"os"
"path/filepath"

"github.com/ethereum/go-ethereum/params"
cli "gopkg.in/urfave/cli.v1"
)

Expand Down Expand Up @@ -76,7 +72,7 @@ type FlagGroup struct {
Flags []cli.Flag
}

// byCategory sorts an array of FlagGroup by Name in the order
// ByCategory sorts an array of FlagGroup by Name in the order
// defined in AppHelpFlagGroups.
type ByCategory []FlagGroup

Expand Down Expand Up @@ -108,14 +104,3 @@ func FlagCategory(flag cli.Flag, flagGroups []FlagGroup) string {
}
return "MISC"
}

// NewApp creates an app with sane defaults.
func NewApp(gitCommit, gitDate, usage string) *cli.App {
app := cli.NewApp()
app.Name = filepath.Base(os.Args[0])
app.Author = ""
app.Email = ""
app.Version = params.VersionWithCommit(gitCommit, gitDate)
app.Usage = usage
return app
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package launcher
package main

import (
"github.com/Fantom-foundation/go-opera/config"
Expand Down
27 changes: 12 additions & 15 deletions cmd/opera/launcher/launcher.go → cmd/sonicd/launcher.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package launcher
package main

import (
"fmt"
"github.com/Fantom-foundation/go-opera/cmd/opera/launcher/diskusage"
"github.com/Fantom-foundation/go-opera/cmd/sonicd/diskusage"
"github.com/Fantom-foundation/go-opera/cmd/sonicd/metrics"
"github.com/Fantom-foundation/go-opera/cmd/sonicd/tracing"
"github.com/Fantom-foundation/go-opera/config"
"github.com/Fantom-foundation/go-opera/config/flags"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/params"
"os"
"os/signal"
"sort"
Expand All @@ -20,18 +23,15 @@ import (
"github.com/ethereum/go-ethereum/p2p/discover/discfilter"
"gopkg.in/urfave/cli.v1"

evmetrics "github.com/ethereum/go-ethereum/metrics"
ethmetrics "github.com/ethereum/go-ethereum/metrics"

"github.com/Fantom-foundation/go-opera/cmd/opera/launcher/metrics"
"github.com/Fantom-foundation/go-opera/cmd/opera/launcher/tracing"
"github.com/Fantom-foundation/go-opera/cmdhelper"
"github.com/Fantom-foundation/go-opera/debug"
_ "github.com/Fantom-foundation/go-opera/version"
)

var (
// The app that holds all commands and flags.
app = cmdhelper.NewApp(config.GitCommit, config.GitDate, "the go-opera command line interface")
app *cli.App

nodeFlags []cli.Flag
testFlags []cli.Flag
Expand Down Expand Up @@ -162,11 +162,14 @@ func initApp() {

initFlags()

app = cli.NewApp()
app.Name = "sonicd"
app.Usage = "the go-sonic service"
app.Version = params.VersionWithCommit(config.GitCommit, config.GitDate)
app.Action = lachesisMain
app.HideVersion = true // we have a command to print the version
app.Commands = []cli.Command{
versionCommand,
licenseCommand,
}
sort.Sort(cli.CommandsByName(app.Commands))

Expand All @@ -184,7 +187,7 @@ func initApp() {
// Start metrics export if enabled
metrics.SetupMetrics(ctx)
// Start system runtime metrics collection
go evmetrics.CollectProcessMetrics(3 * time.Second)
go ethmetrics.CollectProcessMetrics(3 * time.Second)
return nil
}

Expand All @@ -196,12 +199,6 @@ func initApp() {
}
}

func Launch(args []string) error {
initApp()
initAppHelp()
return app.Run(args)
}

// opera is the main entry point into the system if no special subcommand is ran.
// It creates a default node based on the command line arguments and runs it in
// blocking mode, waiting for it to be shut down.
Expand Down
16 changes: 16 additions & 0 deletions cmd/sonicd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
"os"
)

func main() {
initApp()
initAppHelp()

if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
File renamed without changes.
File renamed without changes.
16 changes: 1 addition & 15 deletions cmd/opera/launcher/misccmd.go → cmd/sonicd/misccmd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package launcher
package main

import (
"fmt"
Expand All @@ -22,14 +22,6 @@ var (
The output of this command is supposed to be machine-readable.
`,
}

licenseCommand = cli.Command{
Action: license,
Name: "license",
Usage: "Display license information",
ArgsUsage: " ",
Category: "MISCELLANEOUS COMMANDS",
}
)

func version(ctx *cli.Context) error {
Expand All @@ -49,9 +41,3 @@ func version(ctx *cli.Context) error {
fmt.Printf("GOROOT=%s\n", runtime.GOROOT())
return nil
}

func license(_ *cli.Context) error {
// TODO: license text
fmt.Println(``)
return nil
}
2 changes: 1 addition & 1 deletion cmd/opera/launcher/run_test.go → cmd/sonicd/run_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package launcher
package main

import (
"context"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package launcher
package main

import (
"path/filepath"
Expand Down
4 changes: 2 additions & 2 deletions cmd/opera/launcher/usage.go → cmd/sonicd/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

// Contains the geth command usage template and generator.

package launcher
package main

import (
"github.com/Fantom-foundation/go-opera/cmd/sonicd/cmdhelper"
"github.com/Fantom-foundation/go-opera/config"
"io"
"sort"

cli "gopkg.in/urfave/cli.v1"

"github.com/Fantom-foundation/go-opera/cmdhelper"
"github.com/Fantom-foundation/go-opera/debug"
)

Expand Down
7 changes: 5 additions & 2 deletions cmd/sonictool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ package main

import (
"fmt"
"github.com/Fantom-foundation/go-opera/cmdhelper"
"github.com/Fantom-foundation/go-opera/config"
"github.com/Fantom-foundation/go-opera/config/flags"
_ "github.com/Fantom-foundation/go-opera/version"
"github.com/ethereum/go-ethereum/params"
"gopkg.in/urfave/cli.v1"
"os"
"sort"
)

func main() {
app := cmdhelper.NewApp(config.GitCommit, config.GitDate, "the Sonic management tool")
app := cli.NewApp()
app.Name = "sonictool"
app.Usage = "the Sonic management tool"
app.Version = params.VersionWithCommit(config.GitCommit, config.GitDate)
app.Flags = []cli.Flag{
flags.DataDirFlag,
flags.CacheFlag,
Expand Down

0 comments on commit 5f84009

Please sign in to comment.