github.com/alexdevranger/node-1.8.27@v0.0.0-20221128213301-aa5841e41d2d/cmd/swarm/global-store/main.go (about)

     1  // Copyright 2019 The go-ethereum Authors
     2  // This file is part of go-dubxcoin.
     3  //
     4  // go-dubxcoin is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // go-ethereum is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU General Public License
    15  // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package main
    18  
    19  import (
    20  	"os"
    21  
    22  	"github.com/alexdevranger/node-1.8.27/cmd/utils"
    23  	"github.com/alexdevranger/node-1.8.27/log"
    24  	cli "gopkg.in/urfave/cli.v1"
    25  )
    26  
    27  var gitCommit string // Git SHA1 commit hash of the release (set via linker flags)
    28  
    29  func main() {
    30  	err := newApp().Run(os.Args)
    31  	if err != nil {
    32  		log.Error(err.Error())
    33  		os.Exit(1)
    34  	}
    35  }
    36  
    37  // newApp construct a new instance of Swarm Global Store.
    38  // Method Run is called on it in the main function and in tests.
    39  func newApp() (app *cli.App) {
    40  	app = utils.NewApp(gitCommit, "Swarm Global Store")
    41  
    42  	app.Name = "global-store"
    43  
    44  	// app flags (for all commands)
    45  	app.Flags = []cli.Flag{
    46  		cli.IntFlag{
    47  			Name:  "verbosity",
    48  			Value: 3,
    49  			Usage: "verbosity level",
    50  		},
    51  	}
    52  
    53  	app.Commands = []cli.Command{
    54  		{
    55  			Name:    "http",
    56  			Aliases: []string{"h"},
    57  			Usage:   "start swarm global store with http server",
    58  			Action:  startHTTP,
    59  			// Flags only for "start" command.
    60  			// Allow app flags to be specified after the
    61  			// command argument.
    62  			Flags: append(app.Flags,
    63  				cli.StringFlag{
    64  					Name:  "dir",
    65  					Value: "",
    66  					Usage: "data directory",
    67  				},
    68  				cli.StringFlag{
    69  					Name:  "addr",
    70  					Value: "0.0.0.0:3033",
    71  					Usage: "address to listen for http connection",
    72  				},
    73  			),
    74  		},
    75  		{
    76  			Name:    "websocket",
    77  			Aliases: []string{"ws"},
    78  			Usage:   "start swarm global store with websocket server",
    79  			Action:  startWS,
    80  			// Flags only for "start" command.
    81  			// Allow app flags to be specified after the
    82  			// command argument.
    83  			Flags: append(app.Flags,
    84  				cli.StringFlag{
    85  					Name:  "dir",
    86  					Value: "",
    87  					Usage: "data directory",
    88  				},
    89  				cli.StringFlag{
    90  					Name:  "addr",
    91  					Value: "0.0.0.0:3033",
    92  					Usage: "address to listen for websocket connection",
    93  				},
    94  				cli.StringSliceFlag{
    95  					Name:  "origins",
    96  					Value: &cli.StringSlice{"*"},
    97  					Usage: "websocket origins",
    98  				},
    99  			),
   100  		},
   101  	}
   102  
   103  	return app
   104  }