How to simulate the core process crash of AnQiCMS to comprehensively test the automatic restart capability of the `start.sh` script?

Calendar 👁️ 61

As an experienced security CMS website operator, I am well aware of the importance of system stability and rapid recovery capabilities for content platforms.Even the most robust systems may terminate their core processes due to unforeseen reasons.This is when a reliable automatic pull-up mechanism becomes the last line of defense to ensure the continuous operation of the website.start.shThe script is exactly for this.

The following will detail how to simulate the core process crash of AnQi CMS, for comprehensive testing.start.shThe automatic restart ability of the script.

The importance of automatic recovery of the core process.

In daily operations, we strive for a website that is always online.No matter whether it is due to server resource exhaustion, code exceptions, external attacks, or operation and maintenance mistakes, any event that causes the security CMS core process to stop may lead to service interruption of the website, which in turn affects user experience and business benefits.start.shScript and suggest using time-based tasks (such as Cron) to periodically check and restart the main process, ensuring that the system can self-repair even when unattended.This capability is a key component of the Anqi CMS high availability commitment and is also an important link that we as operators need to verify regularly.

Understandingstart.shThe working principle of the script

According to the Anqi CMS documentation,start.shThe core logic of the script is "Check-Judge-Execute". It first looks for the name ofanqicmsThe core process exists. If the process query findsanqicmsThe process does not exist (i.e.),exists -eq 0The script will judge that the core service has stopped and will restart in the background (using)nohupand&).anqicmsExecutable file. All checks and startup logs will be recorded.check.logandrunning.logChinese. This script is usually configured as a cron job that runs every minute to achieve real-time process monitoring and automatic startup.

The premise condition for testing the automatic pull-up ability

Before conducting any simulation tests, we need to ensure that the test environment is properly configured. This includes the normal installation of the security CMS,start.shThe correct deployment of the script, as well as a running scheduled task to periodically execute the script.

First, please confirm that your security CMS has been deployed on a Linux server according to the official documentation, and the core executable file (usually asanqicms) is located atBINPATHIn the specified directory. For example, ifBINPATHis set to/www/wwwroot/anqicms.comthenstart.shthe script itself as well asanqicmsthe executable files should be located in the directory.

Secondly, be sure to check that the scheduled task (such as Crontab) is properly configured and ensure that it can execute at the set frequency (recommended once a minute)start.shscript. You can check by viewing/var/log/cronorsyslog(The specific log path may vary depending on the Linux distribution) to verify that the Crontab task has been triggered. In addition, you can also manually execute oncestart.shscript and checkBINPATHUnder the directorycheck.logCheck if there are any new log entries generated to confirm that the script is running normally and logging.

Simulate a core process crash and test the automatic recovery steps

We will simulate the unexpected termination of the security CMS core process in a controlled experiment and observestart.shthe automatic recovery behavior of the script

We first need to perform initial setup and verification.Ensure that the Anqi CMS is running and the website is accessible.You can access your safe CMS site via the browser to confirm that the home page content is displayed correctly.ps -ef | grep anqicms | grep -v grepcommands to search foranqicmsProcess, and note down its process ID (PID). If everything is normal, you should see one or moreanqicmsprocess entries. At the same time, checkBINPATH/running.logFile, confirm that there are no obvious error messages when the service starts.

Next is the simulation of the core process crash. To simulate a system-level, abnormal termination, we will usekill -9Command to force stopanqicmsProcess.This is a 'hard kill' operation, which will immediately terminate the process without giving the process any opportunity to clean up and close, which is very similar to the effect of the program crashing due to a serious error.kill -9 <PID>of which<PID>is the one you noted downanqicmsProcess ID. After executing the command, use the command againps -ef | grep anqicms | grep -v grepcommand to confirm allanqicmsThe process has been stopped. At this point, your website should become inaccessible or display an error page.

After the simulated crash, we will observe the automatic recovery process of the system. Due tostart.shThe script is configured to run every minute, just wait patiently for about a minute, letting the scheduled task detect itanqicmsThe process is missing and try to restart it. In the meantime, you can periodically try to access your website and observe when it returns to normal.

Finally, we need to verify and log the recovery results. After the website is restored to access, use it againps -ef | grep anqicms | grep -v grepcommand, you should see a newanqicmsThe process is running, its PID will be different from the previously terminated process. More importantly, we should check the log files for direct evidence. OpenBINPATH/check.logFile, you will see a log indicating a time pointanqicmsThe number of processes is 0. Subsequently, you should see in the subsequent log entriesanqicms NOT runningand the records of the service being restarted. At the same time, checkBINPATH/running.logfile, you should be able to see the newly startedanqicmsprocess initialization and runtime logs. These log entries collectively confirm thatstart.shThe script successfully detected a process crash and effectively restarted the core service.

Summary

Through the above detailed simulation and verification steps, we can comprehensively test the security CMS.start.shThe automatic startup ability of the script.This test not only verifies the system's resilience in the face of unexpected termination of core processes, but also enhances our confidence in the stable operation of Anqi CMS.In actual operation, having such a reliable automatic recovery mechanism can greatly reduce the service interruption time caused by unexpected events, ensuring the continuity of website business and a good user experience.

Frequently Asked Questions (FAQ)

Question: Why choose?kill -9Instead of otherkillCommand to simulate a crash?Answer:kill -9The command will send oneSIGKILLThe signal will force the operating system to immediately terminate the target process without giving the process any chance to handle the exit signal.This best simulates the situation where a program crashes suddenly due to irreversible errors (such as memory access conflicts, segmentation faults, etc.)killCommand (such askillSentSIGTERM) Allows the process to catch signals and perform cleanup operations, which is more like a normal shutdown than a crash.

Question: Ifstart.shThe script did not successfully start the process, how should I troubleshoot the problem?Answer: First, checkBINPATH/check.logandBINPATH/running.logFiles, they are the primary sources for troubleshooting issues.check.logIt will displaystart.shWhether the script has been executed and its judgment on the process state;running.logIt will recordanqicmsOutput and error information when the executable file starts. Common issues may includeBINPATHorBINNAMEConfiguration errors, ports occupied (you can uselsof -i:<端口号>Check), database connection issues, insufficient file permissions, etc. You can also try to manually start withnohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &command startanqicmsobserve whether there is more detailed error output.

Question:start.shCan the script be configured to run for different users?Answer: Yes, it is usually possible to specify which user should execute the task when configuring the Crontab job. For example, edit/etc/crontabor usesudo crontab -e -u <用户名>Add a Crontab task for a specific user. Make sure it executesanqicmsThe user of the process has access toBINPATHDirectory,anqicmsExecutable files and log files (check.logandrunning.logRead and write permissions. In panel environments such as Baota, it is usually default thatwwwthe user runs, you need to make sure the user has sufficient permissions.

Related articles

Does the writing of `start.sh` and `stop.sh` scripts follow the Linux shell script practices and security standards?

As an expert in website operation familiar with Anqi CMS, I know that system stability and security are crucial for the daily operation of any website.The startup and shutdown scripts are critical components for managing AnQiCMS services in the Linux environment, and their coding quality directly affects the reliability and maintainability of the system.Next, I will analyze the `start.sh` and `stop.sh` scripts of AnQiCMS in detail based on the provided AnQiCMS document, evaluating their performance in terms of Linux shell script practices and security standards.

2025-11-06

How does the Go language high concurrency architecture of AnQiCMS协同with process guardian scripts to ensure the high performance and stability of the system?

AnQiCMS is an enterprise-level content management system developed based on the Go language, which has always put high performance and high availability as its core competitiveness since its inception.In actual operation, website performance and stability are the key to attracting and retaining users.AnQiCMS through its unique Go language high concurrency architecture design, combined with mature process guardian scripts, jointly builds a robust system that can withstand huge traffic pressure and ensure continuous online services.

2025-11-06

How to verify that the `start.sh` and `stop.sh` scripts are configured correctly and valid when deploying AnQiCMS via the command line?

As a senior security CMS website operation personnel, I fully understand the importance of a stable and reliable deployment plan for the continuous operation of the website.Especially in the command-line environment, scripts like `start.sh` and `stop.sh` are crucial for AnQiCMS to maintain vitality and cope with emergencies.They are not only responsible for starting and stopping services, but also quietly ensure the robustness of the system in the background.Therefore, verifying the configuration of these scripts for correctness and validity is an indispensable step after deploying AnQiCMS.###

2025-11-06

After upgrading from AnQiCMS 2.x version to 3.x version, is the PID detection in the old `start.sh` scheduled task still applicable?

As an experienced CMS website operation personnel of an enterprise, I fully understand the importance of system stability and management efficiency for content operation.About the issue you raised regarding whether the PID detection in the old `start.sh` scheduled task still applies after upgrading from AnQiCMS 2.x to 3.x version, I can provide you with a detailed answer.In the AnQiCMS 2.x version, to ensure the AnQiCMS application written in Go language can run stably and continuously, especially after server restarts or unexpected program exits, it can recover automatically

2025-11-06

Is the traditional `start.sh` process guardian method still necessary when deploying AnQiCMS in Docker containers?

As a website manager who is deeply familiar with AnQiCMS (AnQiCMS) operation, I deeply understand that efficiency, stability, and scalability are core considerations when deploying and maintaining a website.With the popularity of containerization technology, many teams choose Docker to deploy AnQiCMS.This naturally leads to a key question: Is the traditional `start.sh` process guardian method still necessary when deploying AnQiCMS in Docker containerization?

2025-11-06

Why does the AnQiCMS `stop.sh` script use the `pwd` command to determine BINPATH?

As an experienced secure CMS website operator, I am well aware of the importance of the stable operation of the content management system for the business of the website.In routine maintenance, we frequently deal with the startup and shutdown scripts of the system.For Anqi CMS, its `stop.sh` script uses the `pwd` command to dynamically determine the `BINPATH` variable, which reflects the designer's careful consideration of system robustness and user convenience.The Anqi CMS is a system developed based on the Go language, dedicated to providing an efficient and customizable content management solution

2025-11-06

How should the `start.sh` script-generated `check.log` and `running.log` log files be managed and cleaned on a regular basis?

As a website operator who has been dealing with Anqi CMS for a long time, I know that the stable operation of the system cannot be separated from meticulous maintenance work.The log file, as a faithful recorder of the system's status, is of great importance.However, if not properly managed, they may also become potential sources of problems, such as occupying a large amount of disk space, reducing troubleshooting efficiency, and so on.

2025-11-06

What is the special meaning of the `\<` and `\>` symbols in the `grep` command when matching process names in the `start.sh` script?

As an experienced soldier who deeply understands the operation of AnQiCMS, I know that stable system operation is the foundation of content creation and distribution.When maintaining the AnQiCMS server, we often encounter situations where we need to check or manage processes, and the `start.sh` script is a key component to ensure that the AnQiCMS service remains online.In the `start.sh` script, there is a line used to check if the AnQiCMS process is running, which includes the `grep` command and the unique `<` and `>` symbols, which seem to be simple characters

2025-11-06