@@ -2,7 +2,6 @@ package s
2
2
3
3
import (
4
4
"fmt"
5
- "github.com/ssgo/u"
6
5
"os"
7
6
"os/exec"
8
7
"path"
@@ -11,6 +10,8 @@ import (
11
10
"strings"
12
11
"time"
13
12
13
+ "github.com/ssgo/u"
14
+
14
15
"github.com/ssgo/httpclient"
15
16
)
16
17
@@ -122,29 +123,31 @@ func tryStartPath(testFile string) string {
122
123
123
124
var shellFile = ""
124
125
125
- func init () {
126
+ func initStarter () {
126
127
shellFile , _ = filepath .Abs (os .Args [0 ])
127
128
128
- startPath := ""
129
- if startPath == "" && len (os .Args ) > 1 && strings .ContainsRune (os .Args [1 ], '.' ) {
130
- startPath = tryStartPath (os .Args [1 ])
131
- }
132
- if startPath == "" && len (os .Args ) > 2 && strings .ContainsRune (os .Args [2 ], '.' ) {
133
- startPath = tryStartPath (os .Args [2 ])
134
- }
135
- if startPath == "" {
136
- startPath = tryStartPath ("env.yml" )
137
- }
138
- if startPath == "" {
139
- startPath = tryStartPath ("env.json" )
140
- }
129
+ if workPath == "" {
130
+ if workPath == "" && len (os .Args ) > 1 && strings .ContainsRune (os .Args [1 ], '.' ) {
131
+ workPath = tryStartPath (os .Args [1 ])
132
+ }
133
+ if workPath == "" && len (os .Args ) > 2 && strings .ContainsRune (os .Args [2 ], '.' ) {
134
+ workPath = tryStartPath (os .Args [2 ])
135
+ }
136
+ if workPath == "" {
137
+ workPath = tryStartPath ("env.yml" )
138
+ }
139
+ if workPath == "" {
140
+ workPath = tryStartPath ("env.json" )
141
+ }
141
142
142
- if startPath != "" {
143
- _ = os .Chdir (startPath )
144
- } else if ! strings .Contains (shellFile , "/go-build" ) {
145
- _ = os .Chdir (path .Dir (shellFile ))
143
+ if workPath == "" && ! strings .Contains (shellFile , "/go-build" ) {
144
+ workPath = path .Dir (shellFile )
145
+ }
146
+ }
147
+ if workPath != "" {
148
+ _ = os .Chdir (workPath )
146
149
}
147
- serviceInfo = serviceInfoType {pidFile : filepath .Join (startPath , ".pid" )}
150
+ serviceInfo = serviceInfoType {pidFile : filepath .Join (workPath , ".pid" )}
148
151
serviceInfo .load ()
149
152
150
153
//if len(os.Args) > 1 {
0 commit comments