Skip to content

Commit 8ad4e0c

Browse files
authored
[Feature] Add pid-file to arangosync (#280)
1 parent 0925dd7 commit 8ad4e0c

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
/arangodb
33
bin
44
vendor/
5+
6+
#IDE's
7+
.idea
8+

service/arangosync_config_builder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func createArangoSyncArgs(log zerolog.Logger, config Config, clusterConfig Clust
152152
optionPair{"--server.port", myPort},
153153
optionPair{"--monitoring.token", config.SyncMonitoringToken},
154154
optionPair{"--master.jwt-secret", config.SyncMasterJWTSecretFile},
155+
optionPair{"--pid-file", getLockFilePath(myContainerDir)},
155156
)
156157
if config.DebugCluster {
157158
options = append(options,

service/runner_process.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ type process struct {
5959
isChild bool
6060
}
6161

62+
// getLockFilePath returns path to the file with the lock for the given server directory.
63+
func getLockFilePath(serverDir string) string {
64+
return filepath.Join(serverDir, "data", "LOCK")
65+
}
66+
6267
func (p *process) WaitCh() <-chan struct{} {
6368
c := make(chan struct{})
6469

@@ -71,17 +76,18 @@ func (p *process) WaitCh() <-chan struct{} {
7176
return c
7277
}
7378

74-
func (r *processRunner) GetContainerDir(hostDir, defaultContainerDir string) string {
79+
func (r *processRunner) GetContainerDir(hostDir, _ string) string {
7580
return hostDir
7681
}
7782

7883
// GetRunningServer checks if there is already a server process running in the given server directory.
7984
// If that is the case, its process is returned.
8085
// Otherwise nil is returned.
8186
func (r *processRunner) GetRunningServer(serverDir string) (Process, error) {
82-
lockContent, err := ioutil.ReadFile(filepath.Join(serverDir, "data", "LOCK"))
87+
lockFile := getLockFilePath(serverDir)
88+
lockContent, err := ioutil.ReadFile(lockFile)
8389
if os.IsNotExist(err) {
84-
r.log.Debug().Msgf("Cannot find %s", filepath.Join(serverDir, "data", "LOCK"))
90+
r.log.Debug().Msgf("Cannot find %s", lockFile)
8591
return nil, nil
8692
} else if err != nil {
8793
return nil, maskAny(err)

0 commit comments

Comments
 (0)