Skip to content

Commit a58faea

Browse files
authored
Revert "feat(cmd): process launcher check if are present another ista… (#475)
* Revert "feat(cmd): process launcher check if are present another istances. fixes #168" This reverts commit 8f58798. * chore: update go mod files
1 parent 0064b4f commit a58faea

File tree

7 files changed

+2
-36
lines changed

7 files changed

+2
-36
lines changed

ACKNOWLEDGEMENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ immudb uses the following amazing open source projects. Copyright by their respe
4444
| [gotenv](https://github.com/subosito/gotenv) | [MIT](https://github.com/subosito/gotenv/blob/master/LICENSE) |
4545
| [poly1305](https://github.com/aead/poly1305) | [MIT](https://github.com/aead/poly1305/blob/master/LICENSE) |
4646
| [Go CORS handler](https://github.com/rs/cors) | [MIT](https://github.com/rs/cors/blob/master/LICENSE) |
47-
| [Process List Library for Go](https://github.com/mitchellh/go-ps/) | [MIT](https://github.com/mitchellh/go-ps/blob/master/LICENSE.md) |
47+

cmd/helper/detached.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ package helper
1818

1919
import (
2020
"fmt"
21-
"github.com/codenotary/immudb/cmd/version"
22-
"github.com/mitchellh/go-ps"
2321
"os"
2422
"os/exec"
2523
"path/filepath"
26-
"strings"
2724
"time"
2825
)
2926

@@ -45,7 +42,6 @@ func (e execs) Command(name string, arg ...string) *exec.Cmd {
4542

4643
type Plauncher interface {
4744
Detached() error
48-
Process(processName string) (found bool, p ps.Process, err error)
4945
}
5046

5147
type plauncher struct {
@@ -66,10 +62,6 @@ func (pl plauncher) Detached() error {
6662
return err
6763
}
6864

69-
if exists, p, _ := pl.Process(version.App); exists {
70-
return fmt.Errorf("%s is already running. Pid %d", version.App, p.Pid())
71-
}
72-
7365
for i, k := range os.Args {
7466
if k != "--"+DetachedFlag && k != "-"+DetachedShortFlag && i != 0 {
7567
args = append(args, k)
@@ -89,17 +81,3 @@ func (pl plauncher) Detached() error {
8981
Green, filepath.Base(executable), Blue, cmd.Process.Pid, Reset)
9082
return nil
9183
}
92-
93-
//Process find a process with the given name
94-
func (pl plauncher) Process(processName string) (found bool, p ps.Process, err error) {
95-
ps, err := ps.Processes()
96-
if err != nil {
97-
return false, p, err
98-
}
99-
for _, p1 := range ps {
100-
if strings.Contains(p1.Executable(), processName) {
101-
return true, p1, nil
102-
}
103-
}
104-
return false, nil, nil
105-
}

cmd/helper/detached_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package helper
1818

1919
import (
2020
"bytes"
21-
"github.com/codenotary/immudb/cmd/version"
2221
"github.com/stretchr/testify/assert"
2322
"os/exec"
2423
"strings"
@@ -36,8 +35,7 @@ func (e execsmock) Command(name string, arg ...string) *exec.Cmd {
3635
}
3736

3837
func TestDetached(t *testing.T) {
39-
version.App = "notexists"
40-
pl := plauncher{e: execsmock{}}
38+
pl := plauncher{execsmock{}}
4139
err := pl.Detached()
4240
assert.Nil(t, err)
4341
}

cmd/immudb/command/cmd.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ func (cl *Commandline) Immudb(immudbServer server.ImmuServerIf) func(*cobra.Comm
106106
if options.Detached {
107107
if err := cl.P.Detached(); err == nil {
108108
return nil
109-
} else {
110-
c.QuitToStdErr(err)
111109
}
112110
}
113111

cmd/immudb/command/cmd_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package immudb
1818

1919
import (
2020
"bytes"
21-
"github.com/mitchellh/go-ps"
2221
"os"
2322
"testing"
2423

@@ -210,7 +209,3 @@ type plauncherMock struct{}
210209
func (pl plauncherMock) Detached() error {
211210
return nil
212211
}
213-
214-
func (pl plauncherMock) Process(processName string) (found bool, p ps.Process, err error) {
215-
return false, nil, nil
216-
}

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
github.com/jaswdr/faker v1.0.2
1717
github.com/mattn/go-runewidth v0.0.9 // indirect
1818
github.com/mitchellh/go-homedir v1.1.0
19-
github.com/mitchellh/go-ps v1.0.0
2019
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
2120
github.com/nsf/termbox-go v0.0.0-20200418040025-38ba6e5628f1 // indirect
2221
github.com/o1egl/paseto v1.0.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j
157157
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
158158
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
159159
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
160-
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
161-
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
162160
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
163161
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
164162
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=

0 commit comments

Comments
 (0)