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

Calendar 👁️ 58

AnQiCMS, as an efficient content management system built based on the Go language, is renowned for its lightweight and high-performance in command-line deployment environments.The characteristics of the Go language make AnQiCMS typically compiled into a standalone binary file, which simplifies deployment, but it 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 completely exited, avoiding resource occupation or potential service conflicts, is a critical step to ensure the stable operation of the system and avoid the appearance of 'zombie processes'.

Understanding the essence of AnQiCMS process

In Linux and other operating systems, a Go application usually appears as a single main process.This process carries all the core functions of AnQiCMS, including web services, database connection pool, background task scheduling, and so on.When we start the service according to the AnQiCMS command line deployment tutorial, for example, by executingstart.shScript, the executable file of AnQiCMS (usually namedanqicmsWould benohupThe command is run in the background. This means that even if we close the SSH terminal session, the AnQiCMS service will continue to provide.

Therefore, when we decide to stop the AnQiCMS service, our main goal is to ensure that this main process is terminated safely and completely.Although the Go language's own concurrency model (Goroutine) runs efficiently within a single process and usually does not generate independent subprocesses, in some extreme cases, such as program crashes or configuration issues, unexpected resource usage may occur.

The official way to stop the AnQiCMS service:stop.shscript

The developers of AnQiCMS have prepared a convenient service management script for us,stop.shThis is used to stop the service. The core logic of this script is usually to find the process namedanqicmsand then sendkill -9a signal to force termination.

For example,stop.shThe simplified logic of the script may look like this:

#!/bin/bash
BINNAME=anqicms
exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |awk '{printf $2}'`

if [ $exists -eq 0 ]; then
    echo "$BINNAME NOT running"
else
    echo "$BINNAME is running"
    kill -9 $exists
    echo "$BINNAME is stop"
fi

Thiskill -9The method ensures that even if AnQiCMS encounters certain deadlock situations, it can be effectively closed, which is a means of forcibly terminating the process without leaving an opportunity for the process to clean up resources. During the execution./stop.shAfter the command, we would usually think that the service has stopped. But as a meticulous operations expert, it is indispensable to carry out subsequent confirmation work to ensure that everything is in place.

How to confirm that all related processes have exited?

After the service has stopped, we need to go through several steps to verify.anqicmsIs the main process really exited, and has the port resources it occupied also been released?

Firstly, the most direct and most commonly used method is to usepsThe command to check the process list. In the command line, we can combinegrepThe command to filter outanqicms: related processes:

ps -ef | grep anqicms | grep -v grep

The meaning of this command is:ps -efList the details of all running processes on the system (including user, PID, CPU usage, etc.), then pass it through a pipeline|Pass the output togrep anqicmsThis step will filter all lines containing the keyword "anqicms". Finally, we will usegrep -v grepto excludegrep anqicmsThis command itself generates the process, ensuring that we see the process of the AnQiCMS service itself.

If there is no output after the command is executed, then Congratulations to you,anqicmsThe main process has successfully exited. If you still see similar linesroot 12345 1 ... /path/to/anqicmsthen it meansanqicmsthe process is still running, and we need to handle it further.

Secondly, in addition to the main process itself, sometimes AnQiCMS may not release the network port it occupies in time due to abnormal exit.This may hinder the normal startup of the next service because the new AnQiCMS instance will not be able to bind to the port that is already occupied.We can pass throughlsofCommand to check the occupation of a specific port. AnQiCMS uses it by default.8001Port, so we can check it like this:

lsof -i:8001

lsof -i:<port_number>The command lists all files or processes that have opened the specified network port. Ideally, after executing this command, there should be no output. If you see something similaranqicms 12345 user ...This line indicates that the port is still occupied by a process with PID12345ofanqicmsThe process is occupying. This usually meansanqicmsThe process may not be running inps -efIt is displayed in a clear way to show its web service functions, but it is still running in the background in some form and holding the port.At this time, you can record this PID for future processing.

Finally, although it is not a direct process exit confirmation, but check AnQiCMS'srunning.log(Instart.shThe log output is usually specified to this file) or system log file (for example, on Systemd systems usingjournalctl -u <your_anqicms_service>or check `/var

Related articles

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

How to smoothly migrate old data after stopping the AnQiCMS project and redeploying a new version?

In the dynamic journey of website operation, technological iteration and upgrade is the norm.How can you ensure that the data of the old website can be seamlessly migrated to the new environment when you decide to stop the current AnQiCMS project and plan to deploy a completely new and more powerful version, while minimizing business disruption, which is a key challenge that every operator must face.As an experienced website operations expert, I am well aware of the importance of data. Next, I will elaborate on the strategy and steps of this smooth migration based on the characteristics of AnQiCMS and relevant documents.

2025-11-06

What is the relationship between the port configuration in the `config.` file of AnQiCMS and stopping/startup?

In the daily operation and maintenance of AnQi CMS, we often deal with various configuration files.Among them, the `config.` file is undoubtedly one of the 'lifelines' for the operation of AnQiCMS, carrying the core parameters for system startup.Today, as a veteran with many years of experience in website operations, I will delve into the configuration of the `config.` file regarding ports, as well as its inseparable connection with the start and stop of AnQiCMS services.

2025-11-06

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 set up an automation script for AnQiCMS to stop automatically under certain conditions?

In the daily operation of the website, although we strive for the stability and efficiency of the system, but sometimes for the consideration of maintenance, resource optimization or dealing with emergencies, we need to timely 'let the system take a break.'AnQiCMS is a high-performance content management system built based on the Go language, serving a large number of users with its concise and efficient architecture. However, even such an excellent system still requires careful management on our part as operators.Today, let's discuss how to set up an automated script for AnQiCMS to stop automatically under certain conditions, thus achieving more intelligent and hassle-free operation and maintenance

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