What is the main function of the startup script `start.sh` written by "author fesion" in the AnQiCMS task schedule?

Calendar 👁️ 60

In the daily operation of AnQiCMS (AnQiCMS), the stable operation of the system is the key to ensuring user experience and content distribution efficiency.To ensure that the AnQiCMS service can provide content continuously and uninterruptedly, even if it encounters an unexpected interruption, a meticulously designed startup script plays a crucial role in the scheduled task.Among them, written by 'author fesion'start.shThe script is born for this, it constitutes the core of the self-protection mechanism of AnQiCMS services.

start.shThe core function of the script

start.shThe main function of the script is to monitor the running status of the AnQiCMS application and ensure that it runs continuously in the specified path.In short, it is a lightweight watchdog script that regularly checks if the AnQiCMS main program is running.Once the service stops running, it will immediately attempt to restart the program to minimize service downtime and ensure the continuous availability of the website.This mechanism is crucial for enhancing the robustness and automated operation capabilities of AnQiCMS, especially suitable for small and medium-sized enterprises and self-media operators with limited resources, which can maintain the online status of the service without complex manual intervention.

Analysis of the working principle of the script

thisstart.shThe script is implemented through a series of standard Bash commands. The script first defines two key variables:BINNAME(The name of the AnQiCMS executable program, default asanqicms), andBINPATH(The absolute path of the AnQiCMS program). These variables allow users to flexibly configure according to the actual deployment, ensuring that the script can accurately find and operate the target program.

The core logic of the script is a conditional judgment: it usesps -ef | grep '\<anqicms\>' | grep -v grep | wc -la command chain to check if a system exists namedanqicmsprocess.ps -efList all processes,grep '\<anqicms\>'Filter out processes related to AnQiCMS (\<\>Used for precise matching to prevent matching other unrelated processes containing 'anqicms' in the filename)grep -v grepexcludegrepThe process itself, lastwc -lCount the number of lines that meet the conditions, that is, the number of running AnQiCMS processes.

If the detection results indicate that the number of AnQiCMS processes is zero (i.e.exists -eq 0),The script will determine that AnQiCMS is "not running". At this point, it will executecd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &command to start AnQiCMS.nohupThe command ensures that the AnQiCMS program can continue to run in the background even if the terminal session is closed.>> $BINPATH/running.log 2>&1Then the program's standard output and standard error are redirected torunning.logIn the file, for subsequent log analysis and fault troubleshooting. The entire startup process is performed asynchronously in the background, to avoid blocking the script's execution.

For easy tracking, the script will also record the results of each check and the startup attempts.$BINPATH/check.logIn the file, detailed records of the time and process status were kept, which provided valuable audit clues for operations personnel.

Integration with AnQiCMS scheduled tasks

start.shScripts are typically configured for Linux systemscrontabSchedule a task to run automatically at fixed time intervals (for example, once a minute).In this way, the AnQiCMS service can achieve nearly real-time fault recovery capability.Once the program crashes for any reason (such as memory overflow, code error, external attack, or system resource exhaustion), the scheduled task will detect and restart it in a short period of time, greatly improving the availability of the service.This automated management method is exactly the embodiment of AnQiCMS's 'lightweight and efficient' operation concept, allowing users to focus more energy on content creation and business development rather than being busy dealing with technical failures.


Frequently Asked Questions (FAQ)

1. Ifstart.shThe script is not working as expected, how should I troubleshoot the problem?First, checkBINPATHandBINNAMEAre the variables correctly configured in the script, ensuring they point to the actual path and name of the AnQiCMS executable. Next, checkcheck.logThe file can be used to understand the script's execution history and process detection results, which can help determine whether the script has been correctly scheduled and whether there are any issues with its detection logic. Ifrunning.logThere is content, checking the error information may reveal the reasons for the startup failure of the AnQiCMS program. Finally, you can try to execute manually./start.shObserve the output or use it directly on the serverps -ef | grep anqicmsManually check the process status using the command

2. Whystart.shDoes the script need to run once a minute? Will this frequency consume too many system resources?tostart.shSet to run every minute to achieve rapid fault recovery. If the AnQiCMS service crashes unfortunately, it can be detected and automatically restarted at the latest within one minute.start.shIt is a very lightweight script, mainly performing process checks and simple file I/O operations, with negligible resource consumption.Only when AnQiCMS is indeed not running, will it attempt to perform a real program startup, thus this frequency will not impose a significant burden on system resources, and it is an effective strategy to ensure high availability of the service.

3. When deploying multiple AnQiCMS instances on the same server,start.shWhat are the points that need special attention in the script?When running multiple AnQiCMS instances on the same server, each instance needs to have its independentstart.shscript (or parameterize the main script), and each script must containBINNAMEandBINPATHThe variable must point to independent AnQiCMS executable programs and their installation paths. In addition, each AnQiCMS instance also needs to beconfig.jsonConfigure a unique running port and correctly map it in reverse proxies such as Nginx.Ensure that each instance's scripts, binary files, configuration files, and log files are independent to avoid conflicts and confusion.

Related articles

How to configure Nginx pseudo-static rules for AnQiCMS on the Baota panel?

As an experienced CMS website operation personnel of AnQi, I know that efficient content management and excellent search engine optimization (SEO) play a decisive role in the success of the website.Static page, it is an indispensable part of it, not only does it make the website URL structure more concise and beautiful, but more importantly, it can significantly improve the search engine's ability to capture and understand the content of the website.AnQiCMS was designed with this in mind from the beginning, it has built-in powerful pseudo-static management functions, but to make full use of it, the configuration of Nginx pseudo-static rules on the server side is crucial

2025-11-06

How to install AnQiCMS's Go project on a Linux server?

As a website operator familiar with AnQiCMS, I fully understand the importance of an efficient, stable, and easy-to-manage content system for website operation.AnQiCMS is a modern enterprise-level content management system developed based on the Go language, with its high concurrency, high security, easy deployment, and excellent SEO-friendly features, it has become an ideal choice for many small and medium-sized enterprises and content operation teams.This article will detail how to install and deploy AnQiCMS's Go project on a Linux server, aiming to help you smoothly set up your own website.###

2025-11-06

What operating systems does AnQiCMS support for deployment and use?

As an experienced AnQi CMS website operations personnel, I am very clear about the deployment and usage of AnQi CMS in different operating system environments.AnQiCMS is an enterprise-level content management system developed based on the Go language, which was designed with cross-platform compatibility in mind, aiming to provide users with flexible and diverse deployment options.

2025-11-06

What are the advantages and disadvantages of AnQiCMS using the `start.sh` + `crontab` process guard scheme compared to `systemd` in enterprise-level applications?

As a senior CMS website operation personnel of a well-known security company, I know that the stable and efficient operation of the system is the core of enterprise content management.How to choose the appropriate process protection scheme when deploying AnQiCMS, ensuring that the system can continuously and stably provide services in various situations is a crucial issue.Currently, the AnQiCMS documentation recommends a guard method based on the `start.sh` script combined with `crontab` scheduled tasks.

2025-11-06

How to use the stop script `stop.sh` written by author fesion in AnQiCMS?

AnQiCMS (AnQiCMS) is a high-efficiency and feature-rich Go language content management system, its stable operation cannot do without refined deployment and management.As a website operator, we not only need to pay attention to content creation and optimization, but also ensure the smooth operation of the system backend.In this case, the stop script `stop.sh` plays a crucial role, which can help us safely and effectively manage the lifecycle of AnQiCMS services.### Core function to stop the script `stop.sh` `stop

2025-11-06

How to deploy multiple independent AnQiCMS sites on the same physical server?

In the rapidly changing digital age, businesses and content operators often face the challenge of managing multiple websites.AnQiCMS (AnQiCMS) is an efficient content management system developed based on the Go language, and its multi-site management function is exactly designed to solve this pain point.As an experienced website operator proficient in AnQi CMS, I am well aware of the readers' desire for efficient and convenient solutions.Today, I will elaborate on how to deploy multiple independent security CMS sites on the same physical server, helping you optimize resources and simplify management.## Start Your Multi-Site Journey

2025-11-06

How to configure the new site root directory for AnQiCMS multi-site deployment to achieve data isolation?

As an experienced security CMS website operator, I am well aware of the core role of the content management system in today's digital marketing.Especially when facing the needs of multi-site operations, the powerful functions and flexible configuration provided by AnQiCMS are undoubtedly our reliable assistant.Among them, how to properly configure the root directory of a new site to achieve data isolation is a key link to ensure the efficient and safe operation of multiple sites.

2025-11-06

How to configure reverse proxy through 1Panel when installing AnQiCMS with Docker?

AnQiCMS, as an enterprise-level content management system developed based on the Go language, is an ideal choice for small and medium-sized enterprises and content operation teams with its efficient, secure, and user-friendly features.Combining 1Panel, a convenient server management panel, deploying AnQiCMS via Docker containers can greatly simplify the installation and maintenance process.To allow AnQiCMS to access through a custom domain and hide its internal running port, configuring reverse proxy is an essential step before the website goes into operation.

2025-11-06