@@ -166,6 +166,7 @@ func init() {
166
166
f .BoolSliceVar (& opts .cluster .startCoordinator , "cluster.start-coordinator" , nil , "should a coordinator instance be started" )
167
167
f .BoolSliceVar (& opts .cluster .startActiveFailover , "cluster.start-single" , nil , "should an active-failover single server instance be started" )
168
168
169
+ f .BoolVar (& opts .server .useLocalBin , "server.use-local-bin" , false , "If true, starter will try searching for binaries in local directory first" )
169
170
f .StringVar (& opts .server .arangodPath , "server.arangod" , defaultArangodPath , "Path of arangod" )
170
171
f .StringVar (& opts .server .arangoSyncPath , "server.arangosync" , defaultArangoSyncPath , "Path of arangosync" )
171
172
f .StringVar (& opts .server .arangodJSPath , "server.js-dir" , "/usr/share/arangodb3/js" , "Path of arango JS folder" )
@@ -334,18 +335,18 @@ func slasher(s string) string {
334
335
// findExecutable uses a platform dependent approach to find an executable
335
336
// with given process name.
336
337
func findExecutable (processName , defaultPath string ) (executablePath string , isBuild bool ) {
337
- var pathList = make ([]string , 0 , 10 )
338
- pathList = append (pathList , "build/bin/" + processName )
339
- // Add local folder to search path
338
+ var localPaths []string
340
339
if exePath , err := os .Executable (); err == nil {
341
340
folder := filepath .Dir (exePath )
342
- pathList = append (pathList , filepath .Join (folder , processName + filepath .Ext (exePath )))
341
+ localPaths = append (localPaths , filepath .Join (folder , processName + filepath .Ext (exePath )))
343
342
344
343
// Also try searching in ../sbin in case if we are running from local installation
345
344
if runtime .GOOS != "windows" {
346
- pathList = append (pathList , filepath .Join (folder , "../sbin" , processName + filepath .Ext (exePath )))
345
+ localPaths = append (localPaths , filepath .Join (folder , "../sbin" , processName + filepath .Ext (exePath )))
347
346
}
348
347
}
348
+
349
+ var pathList []string
349
350
switch runtime .GOOS {
350
351
case "windows" :
351
352
// Look in the default installation location:
@@ -385,11 +386,22 @@ func findExecutable(processName, defaultPath string) (executablePath string, isB
385
386
"/usr/local/sbin/" + processName ,
386
387
)
387
388
}
389
+
390
+ if opts .server .useLocalBin {
391
+ pathList = append (localPaths , pathList ... )
392
+ } else {
393
+ pathList = append (pathList , localPaths ... )
394
+ }
395
+
396
+ // buildPath should be always first on the list
397
+ buildPath := "build/bin/" + processName
398
+ pathList = append ([]string {buildPath }, pathList ... )
399
+
388
400
// Search for the first path that exists.
389
401
for _ , p := range pathList {
390
402
if _ , e := os .Stat (filepath .Clean (filepath .FromSlash (p ))); e == nil || ! os .IsNotExist (e ) {
391
403
executablePath , _ = filepath .Abs (filepath .FromSlash (p ))
392
- isBuild = p == "build/bin/arangod"
404
+ isBuild = p == buildPath
393
405
return
394
406
}
395
407
}
0 commit comments