📒 preface

I was happy today, I finished writing A new project (project A), and then I was happy to touch fish. But suddenly someone @me said, another system (item B) 502, I looked, the service is down, let’s restart item B. Then after A while, I found that the service of my newly sent project A was suspended. It was strange, so I restarted project A, and then someone reported that project B was suspended. I gradually found that something was wrong. Then I happily went to look at the code.

🥚 egg – script

Both projects are built using the egg framework, using the egg-script driver, and using the following two commands

{
	"start:sit": "egg-scripts start --port=7080 --env=sit --daemon --title=egg-server-manage-web"."stop": "egg-scripts stop --title=egg-server-manage-web"
}
Copy the code

Every time a project is released, it stops and then starts, and there is a high probability that the stop command will stop another project

🔍 solve

After looking at the document, it is found that the title parameter in egg-script does the following

${appname} –title=egg-server- ${appname}

In simple terms, it is used to alias a process and kill it easily.

If both projects are on the same server and have the same –title, then running the stop command will stop all processes related to the alias. I was in both cases, so when the two projects were restarted, the mutually exclusive behavior occurred.

The solution is simple: just change the –title value