Skip to content

Commit 10a3f0b

Browse files
authored
fix: chmod grpc processes only if needed (#6051)
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 72f4d54 commit 10a3f0b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/model/process.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,14 @@ func (ml *ModelLoader) GetGRPCPID(id string) (int, error) {
9393

9494
func (ml *ModelLoader) startProcess(grpcProcess, id string, serverAddress string, args ...string) (*process.Process, error) {
9595
// Make sure the process is executable
96-
if err := os.Chmod(grpcProcess, 0700); err != nil {
97-
return nil, err
96+
// Check first if it has executable permissions
97+
if fi, err := os.Stat(grpcProcess); err == nil {
98+
if fi.Mode()&0111 == 0 {
99+
log.Debug().Msgf("Process %s is not executable. Making it executable.", grpcProcess)
100+
if err := os.Chmod(grpcProcess, 0700); err != nil {
101+
return nil, err
102+
}
103+
}
98104
}
99105

100106
log.Debug().Msgf("Loading GRPC Process: %s", grpcProcess)

0 commit comments

Comments
 (0)