As an experienced CMS website operation personnel of an enterprise, I know the importance of stable system operation for the content platform.In daily work, we often need to pay attention to various system logs in order to discover and solve potential problems in a timely manner.check.logIn the filePID check: 0A very critical signal, which is when we investigate AnQiCMS process abnormal situations

AnQiCMS process monitoring mechanism andcheck.logthe function

AnQiCMS is a high-performance content management system developed based on the Go language, and its stability is one of its core advantages.To ensure that the system can provide continuous and stable services to the outside world, especially in the face of emergencies, the AnQiCMS deployment plan usually includes an automated process monitoring and maintenance mechanism.start.shto implement a guardian script.

start.shThe script is designed as a scheduled task (for example, throughcrontabExecute once a minute), its primary responsibility is to check if the AnQiCMS application is running. In order to record these check activities and their results, the script will write relevant information to a file namedcheck.logThe log file.This log file is like a sentinel's diary, faithfully recording the status of the AnQiCMS process during each check, providing us with valuable runtime information.

Interpretcheck.logThe "PID check: 0"

When we observecheck.logoccurringPID check: 0such records, it conveys a clear and important message. This line of record isstart.shThe direct output after executing a specific sequence of commands. Specifically, the script will execute similarps -ef | grep '\<anqicms\>' | grep -v grep | wc -lsuch commands to count how many processes namedanqicmsare currently running.

Let's break down this command:ps -efList all running processes in the system:grep '\<anqicms\>'Filter out lines from these processes that contain the keyword "anqicms" (and are complete word matches);grep -v grepFurther excludegrepThe command itself (to prevent false positives); finally,wc -lCount the results after filtering and output the number of matched processes.

Therefore, whencheck.logDisplayPID check: 0This means that atstart.shthe moment the script execution check is performed, the systemNo running AnQiCMS application process found. This '0' represents a process count of zero, indicating that the main process of the AnQiCMS application has stopped or exited abnormally.

Automatic recovery process after abnormal exit.

PID check: 0The appearance is often not an isolated event, but a signal for the self-healing mechanism of AnQiCMS. According tostart.shThe design of the script, once the AnQiCMS process count is 0, the script will immediately judge the current AnQiCMSNot runningIt will automatically execute the startup command of the AnQiCMS application, usually throughnohupThe command runs the AnQiCMS process in the background and redirects the output torunning.logthe file.

This automatic restart logic is designed to minimize service downtime caused by the unexpected termination of processes.This means that even if the AnQiCMS application crashes for some reason (such as memory overflow, code errors, external attacks, or system resource exhaustion), the system is capable of attempting to recover the service on its own within a short period of time, maintaining the online status of the website.

The focus points and troubleshooting ideas of the operations personnel

AlthoughPID check: 0The automatic restart feature that follows brings convenience, but as operation personnel, we cannot be satisfied with this alone. Occasionally,PID check: 0Recorded with a successful restart, it may just be a normal performance of the system self-repair. However, ifcheck.logoccur frequentlyPID check: 0and accompanied byrunning.logThere are a large number of error messages or the AnQiCMS application exits again soon after restart, which needs to be taken seriously.

In this case,PID check: 0It has become a warning signal, indicating that our application may have deep-seated stability issues. At this point, we need to analyze it deeply.running.logFile, find the error stack, exception information, or resource usage before the AnQiCMS application crashes. Also, check the server's system logs (such assyslogordmesgTo determine whether there is an operating system level issue (such as insufficient memory, disk I/O exceptions, etc.) that caused the application to exit abnormally.By conducting these detailed investigations, we can identify the root cause of the problem and take appropriate measures to optimize system configuration, fix code defects, or enhance server resources.


Frequently Asked Questions (FAQ)

1. Why does AnQiCMS need such a process monitoring mechanism?

AnQiCMS uses process monitoring mechanisms to enhance system stability and availability.Any application running for a long time may crash unexpectedly due to various unpredictable factors (such as memory leaks, external attacks, configuration errors, underlying system failures, etc.)start.shThe script checks the process status of AnQiCMS at regular intervals and automatically restarts it, which can achieve the 'self-healing' function of the application, minimize service interruption time, and ensure that the website can continuously provide online services to the outside world.This is a common, efficient service high availability guarantee measure.

2.check.logHow can I troubleshoot when "PID check: 0" frequently appears but the service has not returned to normal?

IfPID check: 0The AnQiCMS application failed to recover successfully, which usually means there are serious startup issues or runtime errors in the application itself. You need to investigate the following:

  • Checkrunning.log: start.shThe script will redirect the standard output and error output of the AnQiCMS program torunning.log.This is the primary file for troubleshooting internal application errors.Check if there is clear error information such as Go language error stack, database connection failure, configuration loading failure, port conflict, etc.
  • Try to start manually:Enter the installation directory of AnQiCMS and try to execute manuallynohup ./anqicms >> running.log 2>&1 &or directly./anqicmsor observe the console output orrunning.logwhether there is immediate error information.
  • Check port occupancy:Confirm that the port configured for AnQiCMS (default is 8001) is not occupied by other applications. You can uselsof -i:{端口号}commands (for examplelsof -i:8001) to check.
  • Check system resources:Check the CPU, memory, and disk space usage on the server to ensure that resources are sufficient. Sometimes, running out of resources can cause the application to fail to start.
  • Check file permissions:Ensure that the AnQiCMS executable file and related directories (such aslog/public/templateetc.) have the correct read/write/execute permissions for thestart.shuser running the script.

3.PID check: 0Does it always mean that there is a problem with the system?

No,PID check: 0It does not always mean that there is a problem with the system.If after this log entry, the system successfully restarted the AnQiCMS service automatically and the service can run stably, then this is just an indication that the monitoring script is working normally and has completed the self-healing process.It indicates that the AnQiCMS application has unexpectedly stopped, but the monitoring system discovered and resolved the issue.PID check: 0Frequent occurrence, the service fails to start successfully, or reappears within a short time after restart, which indicates that there are underlying stability issues that need our intervention and resolution.