How to set up an automation script for AnQiCMS to stop automatically under certain conditions?

Calendar 👁️ 69

In the daily operation of the website, while we pursue system stability and efficiency, sometimes for maintenance, resource optimization, or to deal with emergencies, we need to "let the system rest" in time.AnQiCMS is a high-performance content management system built on the Go language, serving a wide range of users with its concise and efficient architecture. However, even such an excellent system requires careful management from us as operators.Today, let's discuss how to set up an automated script for AnQiCMS to stop automatically under certain conditions, thereby achieving more intelligent and worry-free operation and maintenance.

Understand the stop mechanism of AnQiCMS

To implement automatic shutdown, you must first understand how AnQiCMS is stopped. According to the deployment method of AnQiCMS, the shutdown mechanism is somewhat different:

  1. Deploy directly (Linux command line or Baota panel Go project):AnQiCMS is usually started in the Linux environment through its built-in startup script (start.shRun as a daemon process, accordingly, there is also a stop scriptstop.sh)。Thisstop.shThe core logic of the script is to find the process ID (PID) of AnQiCMS, then usekill -9 PIDCommand to force termination of the process. When we want to automate the stop, the goal is to trigger and execute thisstop.shscript.

  2. Docker container deployment (such as 1Panel, aaPanel, or Baota Docker):In the Docker environment, AnQiCMS runs in an independent container. At this time, we cannot directly call the internalstop.shA script to stop AnQiCMS, but it should be managed through the Docker host's commands to manage the container's lifecycle, namely usingdocker stop <容器名称或ID>command. Automation scripts need to call this Docker command.

  3. Windows Local Test:The Windows environment is typically used for local development or testing. AnQiCMS as aanqicms.exeThe executable file runs. In an automated scenario, you need to manually terminate the process through Task Manager, or use PowerShell script language to find and terminateanqicms.exeProcess.

Considering that Linux server deployment is mainstream, we will mainly discuss script implementation under Linux environment, and briefly mention the differences in the Docker environment.

The core idea of the automation stop script

“Specific conditions”are the key to stopping automation. These conditions can be diverse, such as:

  • Insufficient disk space, reaching the preset threshold.
  • The server CPU or memory usage is consistently too high.
  • The website needs to be deeply maintained during specific times (such as in the early morning).
  • Anomalous log output detected, such as a large number of errors in a short period of time.
  • Received external instructions (for example, by placing a 'stop marker file' at a specific location).

To demonstrate generality and simplicity, we choose to check a“Stop Marking File”Exists to trigger the automation stop of AnQiCMS. When this marking file appears, our automation script will perform the stop operation.

Next, we will implement this automated shutdown process step by step.

1. Prepare the AnQiCMS shutdown script

In the AnQiCMS installation directory, there is usually astop.shscript. Its content is as follows:

`bash #!/bin/bash

stop anqicms

author fesion

the bin name is anqicms

BINNAME=anqicms # Your AnQiCMS executable name BINPATH=\( ( cd " )( dirname “$0” )” && pwd )” # An

Related articles

After the AnQiCMS project stops, can its static resource files still be accessed through CDN?

AnQiCMS (AnQiCMS) is an efficient and customizable content management system that plays a core role in website operations.Regarding the question of whether the static resource files of the 'AnQiCMS' project can still be accessed via CDN after it stops?This question, as an experienced website operations expert, I am well aware that it involves multiple aspects such as website architecture, content distribution mechanism, and CDN working principles.To accurately answer this question, we need to delve deeply into how AnQiCMS manages static resources and how CDN interacts with these resources from two perspectives. First

2025-11-06

How to confirm that all related processes have exited after stopping the service in the AnQiCMS command-line deployment environment?

AnQiCMS, as an efficient content management system built with Go language, is known for its lightweight and high performance in command-line deployment environments.The characteristics of Go language make AnQiCMS usually compiled into an independent binary file, which simplifies deployment, but also means that we need to clearly understand how to manage its lifecycle.Especially when we need to stop the service, how to ensure that all related background processes have been completely exited, to avoid resource occupation or potential service conflicts, is a critical step to ensure the stable operation of the system and prevent the appearance of 'zombie processes'.###

2025-11-06

What specific improvements are mentioned in the "elegant startup and restart" of AnQiCMS's changelog?

As an experienced website operations expert, I am well aware of the importance of a stable and efficient CMS system for the operation of a corporate website.In the update log of AnQiCMS (AnQi CMS), we noticed that the feature of "elegant startup and restart of the blog" was proposed in version v1.0.0-alpha, which was then inherited and developed throughout the AnQiCMS system.This seemingly simple description actually contains profound considerations of AnQiCMS in system design and operation experience.In my opinion

2025-11-06

The AnQiCMS Operation Manual: Easily resolve the startup dilemma of 'port already in use'

When using AnQiCMS to manage your website, you may occasionally encounter a pesky but quite common error: "The port is already in use".As a content management system developed based on Go language, known for its efficiency and stability, AnQiCMS usually runs smoothly.However, when it throws this error during startup or restart, many operators may feel at a loss.Don't worry, this problem is not unique to AnQiCMS, but a challenge that all network service-based applications may encounter.

2025-11-06

Will the database connection of AnQiCMS be immediately disconnected when the project stops?

In the world of website operations, stability and data security are undoubtedly the cornerstone.Many users when evaluating a content management system (CMS) often worry about a seemingly trivial but actually global issue: 'Will the database connection be immediately disconnected when the project stops?'Today, as an experienced website operation expert, I will delve into this issue by combining the technical features and content operation strategy of AnQiCMS (AnQi CMS).

2025-11-06

What will happen to the stop operation if AnQiCMS has unsaved configurations before stopping?

As an experienced website operations expert, I fully understand the core status of configuration management in the Content Management System (CMS), which is directly related to the normal operation of the website, user experience, and even SEO performance.When it comes to AnQiCMS (AnQi CMS) before stopping the service, how would it handle the situation where there are 'unsaved configurations'? This is indeed a question worth delving into, as it touches on the key mechanisms of system data persistence and service lifecycle.To understand this, we first need to clarify how AnQiCMS manages configurations, as well as what its 'stop' operation really means

2025-11-06

How to customize the prompt information for project shutdown or maintenance on the AnQiCMS error page?

The website operation is like a marathon without an end, even with careful maintenance, there will be moments when the site needs a 'rest', whether it be planned system upgrades or unexpected technical maintenance.How to convey information to users at these critical moments, ensuring that they can still feel professional and considerate even when the website is closed, is particularly important.As an experienced user and operator of AnQiCMS, I am well aware of its powerful and flexible customization capabilities in this aspect.

2025-11-06

What does the `docker stop` command mean for AnQiCMS container deployment?

## Deep Analysis: What does the `docker stop` command mean during AnQiCMS container deployment?In the container deployment practice of AnQiCMS, we often deal with Docker commands, among which `docker stop` is a seemingly simple but crucial operation.As an experienced website operations expert, I know that every operations decision can have a profound impact on the stability and data security of the website.

2025-11-06