AnQiCMS is an efficient and feature-rich content management system written in Go language, whose stable operation is inseparable from fine deployment and management.As website operators, we not only need to focus on content creation and optimization, but also ensure the smooth operation of the system backend.stop.sh扮演着一个至关重要的角色,它能够帮助我们安全、有效地管理AnQiCMS服务的生命周期。

Stop the scriptstop.sh的核心功能

stop.shThe main function of the script is to terminate the running process of AnQiCMS application on Linux system.Whether it is for system maintenance, version upgrade, or adjusting configurations, we need a reliable way to stop the running service.This script provides a standardized, command-line friendly way to achieve this goal, avoiding the tediousness and potential errors of manually searching for the process ID (PID) and forcibly terminating it.stop.shIt can ensure that the AnQiCMS service is closed orderly, leaving space for subsequent operations.

Deeply Understandstop.shThe working principle of the script

stop.shThe script is a simple Bash script, its core logic is to find and terminate the AnQiCMS service process. The script includes several key variables and commands that work together to stop the task:

Firstly,BINNAMEThe variable defines the name of the AnQiCMS executable file, the default isanqicms. This name is a key for the script to identify the target process.

Secondly,BINPATHThe variable passes through$( cd "$( dirname "$0" )" && pwd )Command dynamically obtain the directory where the script is located, ensure that the script can be executed correctly at any location, and find the executable file and log file of AnQiCMS.

The script is then usedps -ef | grep '\<anqicms\>' | grep -v grep | awk '{printf $2}'Combine commands to find the process ID of AnQiCMS.

  • ps -efList all running processes.
  • grep '\<anqicms\>'Filter out lines containing "anqicms" (note\<and\>Make sure to match the complete word, not a partial match)
  • grep -v grepExclude it.grepTranslate the process of the command itself to avoid accidental killing.
  • awk '{printf $2}'Extract the second field of the process line, which is the process ID.

If the running process of AnQiCMS is found (i.e.,existsVariable is not 0, the script will usekill -9 $existscommand to force terminate the process.kill -9is a force kill command, meaning it will immediately terminate the process without giving the process a chance to perform cleanup operations.Although this method is usually effective, in some cases, if AnQiCMS is processing critical data, it may lead to inconsistent data.stop.shDefault direct termination mode has been adopted.

Applied in AnQiCMS deploymentstop.sh

stop.shThe script plays a role in various AnQiCMS deployment scenarios:

InBaota Panelin the environment,stop.shCommonly configured as a scheduled task, such as executing once a month, used as part of the maintenance or restart process. Operators can add a Shell script task in the scheduled task interface of the Baota panel.stop.shPaste the content here and set an appropriate execution cycle. Although the document indicates it is executed monthly, in actual operation, we may do it more frequently withstart.shCooperation, used to manually restart the service when needed.

For those who go throughCommand lineDeployed AnQiCMS instance,stop.shThe usage is more direct. Simply execute through the terminal in the AnQiCMS installation directory../stop.shCommand, stop the service. This is very useful for scenarios where services need to be manually managed or for writing automation deployment scripts.

When a server has been deployed withMultiple AnQiCMS siteswhenstop.shThe flexibility becomes particularly important. If each AnQiCMS instance has a different executable file name (for example, to distinguish between different sites), we need to modify it accordingly.stop.shScript insideBINNAMEA variable, to make it match the executable filename of a specific instance.This ensures that we can accurately stop the target site without affecting other running AnQiCMS instances.

InSystem upgradeDuring the process, especially when upgrading from AnQiCMS 2.x version to 3.x version, the document also mentioned stopping the project first using the scheduled task (i.e., runningstop.shThen delete the old plan task and deploy in the new Go project way. This indicatesstop.shIt is a standardized step in the upgrade process, used to ensure that the old service is completely closed so that the new version can start smoothly.

Key considerations and operational suggestions

Usestop.shWhen, as a website operator, we need to pay attention to the following points:.

Firstly,BINNAMEThe accuracy of variables is crucial. If the executable file of AnQiCMS is renamed, it must be updated synchronously.stop.shscript, make sure it points to the correct directory of the AnQiCMS executable file, and that the directory containsBINNAMEOtherwise, the script will not be able to find and stop the correct process.

Secondly,stop.shMainly designed for Linux environments. ForWindows system【en】, AnQiCMS documentation clearly states that there is notstop.sh【en】script, the user needs to manually terminate through the Windows Task Manageranqicms.exeProcess. Therefore, when deploying across platforms, it should be understood that there are these differences.

Finally, executestop.shAfter that, we should go throughps -ef | grep '\<anqicms\>' | grep -v grepCheck again to ensure that the AnQiCMS process has indeed stopped. This is a good operational habit that can avoid service anomalies caused by script execution failure.

In summary,stop.shThe script is an indispensable part of the AnQiCMS service toolbox.It simplifies the operation of stopping services, improves operational efficiency, and provides the necessary flexibility in multi-site and upgrade scenarios.Mastery of its usage and precautions will make the daily management of AnQiCMS smoother and safer.


Common Questions and Answers (FAQ)

stop.shCan the script be used on Windows system?No. According to the official documentation of AnQiCMS,stop.shThe script is designed for Linux environments. On Windows systems, you need to use Task Manager to locate and manually terminateanqicms.exeprocesses to stop the service.

If I change the executable filename of AnQiCMS (for example, fromanqicmstomysite)stop.shCan it still work normally?It cannot work directly. You need to editstop.shthe script file, and change the internalBINNAMEThe value of the variable is updated to the new executable filename (for example,)BINNAME=mysite), to ensure that the script can correctly identify and stop your AnQiCMS instance.start.shThe script also needs to be modified in the same way.

Executestop.shHow to confirm that the AnQiCMS service has stopped?In the Linux terminal, you can useps -ef | grep '\<anqicms\>' | grep -v grepcommand (please replace)anqicmsReplace with your actual executable filename) to check if there is still a process running for AnQiCMS.If no output is displayed, it means that the AnQiCMS service has been successfully stopped.