Skip to content

[BUG] function CheckAndReportBinariesStatus cannot correctly check the number of processes when encountering symbolic link directory situation #4

@neptunezx

Description

@neptunezx

OpenIM Server Version

3.8.1

Operating System and CPU Architecture

macOS (ARM)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

If the project's directory is included in a symbolic link directory, after running mage start in the OpenIM project, CheckBinariesRunning(in CheckAndReportBinariesStatus) cannot correctly check the number of processes. The reason is that in the init function of the mageutil module, the value of the OpenIMRoot variable is obtained via os.Getwd(), which may return a path containing symbolic links, rather than the actual file path. But the underlying implementation of CheckBinariesRunning is based on the proc_pidpath function in C, which retrieves the process path as the true file path (not symbolic link paths).
It will also make the "mage stop" not work to stop processes.
It is recommended to modify the package's init function

func init() {
	currentDir, err := os.Getwd()
	if err != nil {
		panic("Error getting current directory: " + err.Error())
	}

        OpenIMRoot = currentDir

to

func init() {
	currentDir, err := os.Getwd()
	if err != nil {
		panic("Error getting current directory: " + err.Error())
	}
	currentDir, err = filepath.EvalSymlinks(currentDir)
	if err != nil {
		panic("Error resolving symlinks in current directory: " + err.Error())
	}

        OpenIMRoot = currentDir

Screenshots Link

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions