openimsdk / openimsdk/gomake

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

Open
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
15
Forks
30
Avg merge
1m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the mageutil package's init function and trace how OpenIMRoot is used by CheckBinariesRunning within CheckAndReportBinariesStatus. Reproduce the behavior with the project accessed through a symbolic-link directory, then verify that mage start detects processes and mage stop can stop them using the resolved path.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.