~/.tendermint -> .tendermint
This commit is contained in:
parent
4c2e57437b
commit
22fdb6ca2f
|
@ -4,3 +4,5 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
build/*
|
build/*
|
||||||
rpc/test/.tendermint
|
rpc/test/.tendermint
|
||||||
|
.debora
|
||||||
|
.tendermint
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
|
|
||||||
acm "github.com/tendermint/tendermint/account"
|
acm "github.com/tendermint/tendermint/account"
|
||||||
"github.com/tendermint/tendermint/binary"
|
"github.com/tendermint/tendermint/binary"
|
||||||
|
@ -13,18 +12,16 @@ import (
|
||||||
. "github.com/tendermint/tendermint/common"
|
. "github.com/tendermint/tendermint/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Config = struct {
|
||||||
|
Remotes []string
|
||||||
|
PrivKey acm.PrivKey
|
||||||
|
}{}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
remotes []string
|
configFlag = cli.StringFlag{
|
||||||
privKey acm.PrivKey
|
Name: "config-file",
|
||||||
remotesFlag = cli.StringFlag{
|
Value: ".debora/config.json",
|
||||||
Name: "remotes",
|
Usage: "config file",
|
||||||
Value: "http://127.0.0.1:8082",
|
|
||||||
Usage: "comma separated list of remote baraks",
|
|
||||||
}
|
|
||||||
privKeyFlag = cli.StringFlag{
|
|
||||||
Name: "privkey-file",
|
|
||||||
Value: "privkey",
|
|
||||||
Usage: "file containing private key json",
|
|
||||||
}
|
}
|
||||||
waitFlag = cli.BoolFlag{
|
waitFlag = cli.BoolFlag{
|
||||||
Name: "wait",
|
Name: "wait",
|
||||||
|
@ -45,11 +42,10 @@ func main() {
|
||||||
app.Version = "0.0.1"
|
app.Version = "0.0.1"
|
||||||
app.Email = "ethan@erisindustries.com,jae@tendermint.com"
|
app.Email = "ethan@erisindustries.com,jae@tendermint.com"
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
remotesFlag,
|
configFlag,
|
||||||
privKeyFlag,
|
|
||||||
}
|
}
|
||||||
app.Before = func(c *cli.Context) error {
|
app.Before = func(c *cli.Context) error {
|
||||||
remotes, privKey = ParseFlags(c)
|
ReadConfig(c.String("config-file"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
|
@ -71,38 +67,25 @@ func main() {
|
||||||
Name: "stop",
|
Name: "stop",
|
||||||
Usage: "stop process",
|
Usage: "stop process",
|
||||||
Action: cliStopProcess,
|
Action: cliStopProcess,
|
||||||
Flags: []cli.Flag{
|
|
||||||
//remotesFlag,
|
|
||||||
//privKeyFlag,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
cli.Command{
|
cli.Command{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "list processes",
|
Usage: "list processes",
|
||||||
Action: cliListProcesses,
|
Action: cliListProcesses,
|
||||||
Flags: []cli.Flag{
|
|
||||||
//remotesFlag,
|
|
||||||
//privKeyFlag,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
app.Run(os.Args)
|
app.Run(os.Args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseFlags(c *cli.Context) (remotes []string, privKey acm.PrivKey) {
|
func ReadConfig(configFilePath string) {
|
||||||
remotesStr := c.String("remotes")
|
configJSONBytes, err := ioutil.ReadFile(configFilePath)
|
||||||
remotes = strings.Split(remotesStr, ",")
|
|
||||||
privkeyFile := c.String("privkey-file")
|
|
||||||
privkeyJSONBytes, err := ioutil.ReadFile(privkeyFile)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to read privkey from file %v. %v", privkeyFile, err)
|
Exit(Fmt("Failed to read config file %v. %v\n", configFilePath, err))
|
||||||
return remotes, nil
|
|
||||||
}
|
}
|
||||||
binary.ReadJSON(&privKey, privkeyJSONBytes, &err)
|
binary.ReadJSON(&Config, configJSONBytes, &err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Exit(Fmt("Failed to parse privkey. %v", err))
|
Exit(Fmt("Failed to parse config. %v", err))
|
||||||
}
|
}
|
||||||
return remotes, privKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func cliGetStatus(c *cli.Context) {
|
func cliGetStatus(c *cli.Context) {
|
||||||
|
@ -110,7 +93,7 @@ func cliGetStatus(c *cli.Context) {
|
||||||
if len(args) != 0 {
|
if len(args) != 0 {
|
||||||
fmt.Println("BTW, status takes no arguments.")
|
fmt.Println("BTW, status takes no arguments.")
|
||||||
}
|
}
|
||||||
for _, remote := range remotes {
|
for _, remote := range Config.Remotes {
|
||||||
response, err := GetStatus(remote)
|
response, err := GetStatus(remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%v failure. %v\n", remote, err)
|
fmt.Printf("%v failure. %v\n", remote, err)
|
||||||
|
@ -135,8 +118,8 @@ func cliRunProcess(c *cli.Context) {
|
||||||
Args: args,
|
Args: args,
|
||||||
Input: c.String("input"),
|
Input: c.String("input"),
|
||||||
}
|
}
|
||||||
for _, remote := range remotes {
|
for _, remote := range Config.Remotes {
|
||||||
response, err := RunProcess(privKey, remote, command)
|
response, err := RunProcess(Config.PrivKey, remote, command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%v failure. %v\n", remote, err)
|
fmt.Printf("%v failure. %v\n", remote, err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -154,8 +137,8 @@ func cliStopProcess(c *cli.Context) {
|
||||||
command := btypes.CommandStopProcess{
|
command := btypes.CommandStopProcess{
|
||||||
Label: label,
|
Label: label,
|
||||||
}
|
}
|
||||||
for _, remote := range remotes {
|
for _, remote := range Config.Remotes {
|
||||||
response, err := StopProcess(privKey, remote, command)
|
response, err := StopProcess(Config.PrivKey, remote, command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%v failure. %v\n", remote, err)
|
fmt.Printf("%v failure. %v\n", remote, err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -173,8 +156,8 @@ func cliListProcesses(c *cli.Context) {
|
||||||
app := args[0]
|
app := args[0]
|
||||||
*/
|
*/
|
||||||
command := btypes.CommandListProcesses{}
|
command := btypes.CommandListProcesses{}
|
||||||
for _, remote := range remotes {
|
for _, remote := range Config.Remotes {
|
||||||
response, err := ListProcesses(privKey, remote, command)
|
response, err := ListProcesses(Config.PrivKey, remote, command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%v failure. %v\n", remote, err)
|
fmt.Printf("%v failure. %v\n", remote, err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,7 +20,7 @@ func App() *confer.Config {
|
||||||
appMtx.Lock()
|
appMtx.Lock()
|
||||||
defer appMtx.Unlock()
|
defer appMtx.Unlock()
|
||||||
if app == nil {
|
if app == nil {
|
||||||
Init("")
|
Init(".tendermint")
|
||||||
}
|
}
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,6 @@ func initDefaults(rootDir string) {
|
||||||
func Init(rootDir string) {
|
func Init(rootDir string) {
|
||||||
|
|
||||||
// Get RootDir
|
// Get RootDir
|
||||||
if rootDir == "" {
|
|
||||||
rootDir = os.Getenv("TMROOT")
|
|
||||||
}
|
|
||||||
if rootDir == "" {
|
|
||||||
rootDir = os.Getenv("HOME") + "/.tendermint"
|
|
||||||
}
|
|
||||||
configFile := path.Join(rootDir, "config.toml")
|
configFile := path.Join(rootDir, "config.toml")
|
||||||
genesisFile := path.Join(rootDir, "genesis.json")
|
genesisFile := path.Join(rootDir, "genesis.json")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue