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

Calendar 👁️ 66

As a senior security CMS website operations 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,start.shandstop.shThis service management script is the key to keeping AnQiCMS vital and responding to 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 that the configuration of these scripts is correct and valid is an indispensable step after deploying AnQiCMS.

Ensure the robustness of the service start and stop scripts

start.shandstop.shThe script plays a core role in the command line deployment of AnQiCMS.They are the guardians of the lifecycle of the website service, responsible for waking up the AnQiCMS process at system startup and smoothly shutting it down when needed.A misconfigured or failed script can cause the website to fail to go online normally, fail to shut down gracefully, and even fail to automatically restore services after server restart, seriously affecting the availability of the website.Therefore, it is the responsibility of website operators to carefully verify these two scripts to ensure stable system operation.

Script content parsing and preperation

Before we proceed with the verification, we need to understand the basic logic of these two scripts. According to the AnQiCMS deployment document,start.shThe script's main function is to check if the AnQiCMS process exists, and if it does not exist, then pass throughnohupThe command starts AnQiCMS main program in the background and redirects the runtime log torunning.log.stop.shThe script is responsible for finding the PID (Process ID) of the AnQiCMS process and then throughkill -9the command to force terminate the process.

Before starting the verification, please ensure that the following conditions are met:

  • AnQiCMS executable file: Ensure that the binary executable file of AnQiCMS (default asanqicms) Already exists in the specified path.
  • Script file exists:start.shandstop.shThe file already exists in the installation directory of AnQiCMS.
  • File permissions: Ensure that these two scripts andanqicmsAll executable files have execute permission (chmod +x start.sh stop.sh anqicms)
  • Path accuracy: In the scriptBINPATHThe variable should accurately point to the root directory of AnQiCMS installation.
  • Log file is writable:running.logandcheck.logThe file (or its directory) should have write permission so that the script can record logs.

Verify one by onestart.shScript validity

To verifystart.shCan the script correctly start the AnQiCMS service, we need to perform a series of steps.

First, navigate to the installation directory of AnQiCMS in the terminal and then manually executestart.shscript.

cd /www/wwwroot/your_anqicms_path # 替换为你的实际路径
./start.sh

After execution, please closely observe the terminal output, althoughnohupRedirect most of the output to the log file, but there may still be some immediate feedback.

Next, check the log file generated by the script. First, look atcheck.logThe file should record the execution time of the script as well as the check status of the AnQiCMS process. Then, viewrunning.logFile, there should be detailed log output during the startup process of the AnQiCMS service.If the service starts successfully, there will usually be port listening, database connection and other related information.

After confirming that the log is correct, you need to verify whether the AnQiCMS process is indeed running. You can usepscommand to check:

ps -ef | grep anqicms

If you see something similarroot 12345 ... /www/wwwroot/your_anqicms_path/anqicmsThe output indicates that the AnQiCMS process is running and12345its PID is.

Finally, verify the availability of the service via network access. Open your browser and enter the access address configured for AnQiCMS (for examplehttp://your-domain.com:8001Or through the reverse proxy configuration domain), confirm that the website can be displayed normally. If the website can be accessed normally, it indicatesstart.shThe script has successfully started the AnQiCMS service.

Thorough verificationstop.shScript validity

After confirmationstart.shAfter the service starts normally, the next step is to verifystop.shCan the script correctly terminate the AnQiCMS process.

Similarly, navigate to the installation directory of AnQiCMS in the terminal and manually executestop.shscript.

cd /www/wwwroot/your_anqicms_path # 替换为你的实际路径
./stop.sh

Check again after executioncheck.logfile. It should recordstop.shThe execution time of the script, as well as the check and termination information of the AnQiCMS process.

Then, usepsCommand to verify if the AnQiCMS process has been terminated:

ps -ef | grep anqicms

If thisgrepcommand did not return any containinganqicmsresults (exceptgrepits own process), it means the AnQiCMS process has been successfully closed.

To further confirm that the service has stopped, you can uselsofCommand check if the listening port of AnQiCMS has been released. Assuming the default port of AnQiCMS is8001:

lsof -i:8001

If the command does not return any results, it means the port is no longer occupied.

Finally, try to access your AnQiCMS website via the browser. Ifstop.shThe script executed successfully, you should see error messages indicating a connection failure or inability to access, which means the AnQiCMS service has been successfully stopped.

Integrating Crontab and verification strategy afterwards

The deployment of AnQiCMS usually combines Crontab to achieve automatic monitoring and restart of services.Verify whether the Crontab integration is effective, which is crucial for ensuring service resilience.

First, make sure you have alreadystart.shScript is added to the Crontab, usually set to run every minute to achieve the functionality of a daemon. You can view the Crontab configuration with the following command:

crontab -l

Confirm that it contains similar*/1 * * * * /www/wwwroot/anqicms.com/start.sh.

After adding the Crontab task, wait a minute or two, and then check againcheck.logThe file timestamp. If the timestamp is the latest and updates every minute, it indicates that the Crontab is running as expectedstart.shscript.

To simulate the situation of a service crash, you can manually terminate the AnQiCMS process but do not executestop.shFor example, usekill -9The process PID of AnQiCMS found before the command is terminated:

kill -9 [AnQiCMS进程的PID]

After manually terminating the process, wait for one minute and use it againps -ef | grep anqicmsCheck the process list command. If the AnQiCMS process appears again and the PID is different from the previous one, it indicates that Crontab successfully detected the service stop and automatically restarted AnQiCMS in the next cycle, which confirms the effectiveness of the Crontab daemon process.

Troubleshooting and common issues solutions

During verificationstart.shandstop.shDuring the script process, some problems may occur. The following are some common difficulties and their solutions.

One of the most common problems isThe port is already occupiedIf AnQiCMS fails to start or atrunning.logError binding port, it is likely because the default port (such as 8001) is already occupied by another program. You can uselsof -i:{端口号}commands (for examplelsof -i:8001) to find the process occupying the port, and thenkill -9 {PID}Command to terminate the process or modify the AnQiCMS configuration fileconfig.jsonChange its port to another unoccupied port.

Another common issue isThe path or binary filename in the script does not match.start.shandstop.shThe script depends onBINPATHandBINNAMEvariables to locate the AnQiCMS executable file. If these variables are not configured correctly, or if you have changedanqicmsThe name of the executable file without the sync update script, the script will not be able to find and manage the AnQiCMS process. Please check it.start.shandstop.shin the fileBINPATHandBINNAMEIs it consistent with the actual deployment path and executable file name of your project.

Furthermore,Insufficient file permissionsMay also cause the script to fail. Ifstart.shorstop.shThe script does not have execution permissions, or the AnQiCMS log directory does not have write permissions, the script will not work normally or record logs. You should usechmod +x start.sh stop.sh anqicmsEnsure the command makes the script and binary files executable, and useschmod -R 755 /path/to/anqicmsEnsure the log directory is writable.

By following the above detailed verification steps and troubleshooting methods, you should be able to comprehensively and effectively confirm AnQiCMS'sstart.shandstop.shThe script is correctly configured and can run reliably, providing stable content services for your website.


Frequently Asked Questions (FAQ)

1. Why do we need to usestart.shandstop.shScript, rather than directly running the AnQiCMS binary file?

Run the AnQiCMS binary file directly can start the service, but after the terminal is closed, the service will also be terminated.start.shScripts usually usenohupThe command starts the service in the background and redirects its standard output and error output to a log file, ensuring that the service continues to run even after the terminal is closed. Additionally, combined with Crontab,start.shCan act as a daemon, automatically restarting AnQiCMS when it stops unexpectedly, greatly improving the availability and stability of the website.stop.shIt provided a standardized way to terminate the service smoothly.

2. How should I troubleshoot if AnQiCMS does not automatically start after the server restarts?

If AnQiCMS does not automatically start after the server restart, the most common reason isstart.shThe script was not added correctly to the system's startup item or Crontab task. First, please check your Crontab configuration (crontab -l) to ensurestart.shThe script path is correct and the scheduling frequency is sufficient (for example*/1 * * * *). Additionally, you also need to confirmstart.shThe script itself has no errors, and the path and name of the AnQiCMS executable file are correctly configured in the script.Sometimes, when the system restarts, there may be issues with dependent services (such as databases) not starting in time, which may also affect the normal startup of AnQiCMS.

3. I changed the name of the AnQiCMS executable file (for example fromanqicmschanged tomycmsNeed to updatestart.shandstop.shIs this script?

Yes, it is necessary.start.shandstop.shin the scriptBINNAMEvariables andgrepCommands are usually hard-coded to find and manage executable file names. If you change the name of the AnQiCMS executable, you need to modify these two scripts accordingly.BINNAMEVariable, andgrep '\<anqicms\>'ofanqicmsReplace with a new executable filename (for examplegrep '\<mycms\>'). Otherwise, the script will not be able to correctly identify and control your AnQiCMS process.

Related articles

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

Does the `start.sh` script support running the AnQiCMS process with different user identities, how is permission management implemented?

As a senior security CMS website operator, I am well aware of the importance of system stability and permission management for website security and operational efficiency.About the user identity and permission management of the AnQiCMS process running the `start.sh` script, I can elaborate for you.AnQiCMS is a system developed based on the Go language, and its operation and permission settings are different from traditional PHP applications, but the core security concept is the same: the principle of least privilege. `start

2025-11-06

How to modify the `start.sh` script to record more detailed debug information when starting AnQiCMS?

As a deep熟悉 AnQiCMS (AnQiCMS) website operator, I know the importance of system stable operation and efficient problem diagnosis for content management.When AnQiCMS encounters exceptions during runtime or requires a deeper understanding of its internal workflow, obtaining detailed debugging information is a crucial step.`start.sh` script is the entry point for AnQiCMS in the Linux environment, which is the key to modifying it to obtain more debugging information.### Understand `start.sh`

2025-11-06

What is the impact on server performance of setting `*/1 * * * *` to check the AnQiCMS process every minute in `crontab`?

As a website operator who is deeply familiar with the operation of Anqi CMS, I know that the stability and response speed of website services are crucial for attracting and retaining users.The content management system is at the core of the website, and its continuous stable operation is the basis for ensuring efficient content publication and smooth user access.Regarding the setting of `*/1 * * * *` in `crontab` to check the AnQiCMS process every minute, as well as the potential impact on server performance, this is a topic worthy of in-depth discussion.### Ongoing intent and implementation Firstly

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

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 to simulate the core process crash of AnQiCMS to comprehensively test the automatic restart capability of the `start.sh` script?

As an experienced CMS website operation personnel of an enterprise, 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.The `start.sh` script provided by Anqi CMS is for this purpose.

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