Skip to content

Commit 6db901a

Browse files
authored
Merge pull request #2453 from actiontech/fix_plugin_pidfile_nil_pointer
fix: plugin pid file walk nil pointer
2 parents 0c424f8 + ff8209f commit 6db901a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sqle/driver/plugin_manager.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ func (pm *pluginManager) Start(pluginDir string, pluginConfigList []config.Plugi
183183
// kill plugins process residual and remove pidfile
184184
var wg sync.WaitGroup
185185
dir := GetPluginPidDirPath(pluginDir)
186+
if err := os.MkdirAll(dir, 0644); err != nil {
187+
return err
188+
}
186189
if err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
187190
if !info.IsDir() && strings.HasSuffix(info.Name(), ".pid") {
188191
wg.Add(1)
@@ -366,11 +369,8 @@ func GetPluginPidFilePath(pluginDir string, pluginName string) string {
366369
}
367370

368371
func WritePidFile(pidFilePath string, pid int64) error {
369-
_, err := os.Stat(pidFilePath)
370-
if os.IsNotExist(err) {
371-
if err := os.MkdirAll(filepath.Dir(pidFilePath), 0644); err != nil {
372-
return err
373-
}
372+
if err := os.MkdirAll(filepath.Dir(pidFilePath), 0644); err != nil {
373+
return err
374374
}
375375
file, err := os.OpenFile(pidFilePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
376376
if err != nil {

0 commit comments

Comments
 (0)