Svarog a7299c1b87
Add stability tests (#1587)
* Add stability-tests

* Fix requires

* Fix golint errors

* Update README.md

* Remove payloadHash from everywhere

* don't run vet on kaspad in stability-tests/install_and_test
2021-03-09 15:01:08 +02:00

33 lines
992 B
Go

package common
import (
"fmt"
"os/exec"
"strings"
"github.com/kaspanet/kaspad/domain/dagconfig"
"github.com/kaspanet/kaspad/infrastructure/logger"
"github.com/pkg/errors"
)
// StartCmd runs a command as a separate process.
// The `name` parameter is used for logs.
// The command executable should be in args[0]
func StartCmd(name string, args ...string) (*exec.Cmd, error) {
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout = NewLogWriter(log, logger.LevelTrace, fmt.Sprintf("%s-STDOUT", name))
cmd.Stderr = NewLogWriter(log, logger.LevelWarn, fmt.Sprintf("%s-STDERR", name))
log.Debugf("Starting command %s: %s", name, cmd)
err := cmd.Start()
if err != nil {
return nil, errors.WithStack(err)
}
return cmd, nil
}
// NetworkCliArgumentFromNetParams returns the kaspad command line argument that starts the given network.
func NetworkCliArgumentFromNetParams(params *dagconfig.Params) string {
return fmt.Sprintf("--%s", strings.TrimPrefix(params.Name, "kaspa-"))
}