How to check if the AnQiCMS project has stopped successfully and released the port using the `lsof` command?

Calendar 81

Website operation tool: How to uselsofCommand to check if the AnQiCMS project has stopped successfully and released the port?

As a high-performance content management system developed based on the Go language, AnQiCMS also has precise requirements for the use of server resources while pursuing efficiency.Whether it is to carry out system maintenance, version upgrade, or daily deployment adjustment, ensuring that the AnQiCMS project can stop running cleanly and release the ports it occupies is an indispensable link in website operation.A clean shutdown process can avoid port conflicts, resource waste, and lay a good foundation for the next service start.

If the AnQiCMS project does not stop completely, it may continue to occupy its listening port (usually 8001), causing new service instances to fail to start or cause unnecessary trouble during server resource cleanup.At this point, we need a reliable method to verify whether the project has really been 'closed for rest'.

Get to knowlsofPort check Swiss Army Knife:

In Linux or macOS and other Unix-like systems,lsof(list open files) is a powerful command line tool, as the name implies, it can list all the files currently open on the system.But its functionality is not limited to this, we can also use it to view which processes are using specific network ports. This makeslsofis the ideal tool for us to confirm whether the AnQiCMS port is released.

Verify the practical steps for releasing the port of AnQiCMS

Next, we will explain step by step how to uselsofcommands to check the port status of the AnQiCMS project.

The first step: clarify the port number that the AnQiCMS project is listening to

The AnQiCMS project listens on a specific port to provide services when it starts. According to the default configuration of AnQiCMS, this port is usually8001. But in actual deployment, especially in a multi-site environment, you may have already checked according to the project directory underconfig.jsonThe file or other configuration (such as when deploying on Baota panel or 1Panel, different ports such as 8002, 8003, etc. may have been specified) specified different ports.Before performing the check, please make sure to verify the exact port number used by your current AnQiCMS instance.

Second step: ExecutelsofCheck the command

Once the target port is determined, we can execute the command in the terminal tolsofcheck its occupancy. The command format is very intuitive, just replace the{端口号}confirmed port number in the position:

lsof -i:{端口号}

For example, if your AnQiCMS is running on the default8001port, you will execute:

lsof -i:8001

Step 3: Interpretlsofthe output result of the command

After executing the command, you may see two different results, which clearly tell you the running status of AnQiCMS.

Case one: No output from the terminal (ideal state)

If the terminal does not display any information, or only returns the command prompt without listing any processes, congratulations to you!This means that the specified port is currently not occupied by any process, and the AnQiCMS project has been successfully stopped and the port has been released.You can safely proceed to the next step, such as restarting the service or deploying a new version.

Case two: Terminal output process details (port is still occupied)

IflsofThe command returned output information similar to the following format:

COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
anqicms   7621   root    3u  IPv6  80123      0t0  TCP *:8001 (LISTEN)

This indicates the port8001is still being used by a process namedanqicmsProcess ID (PID) is7621occupied by the process. At this time, the AnQiCMS project has not completely stopped. The output showsCOMMANDthe process name, PIDThe column is the unique identifier of the process,NAMEThe column clearly indicates the port and its status (LISTENindicating that it is listening).

Step 4: Manually terminate any remaining processes (if necessary)

When the port is still occupied, we need to manually terminate the relevant processes. Usually, AnQiCMS under the Linux environment can be executed bystop.shScripts to gracefully stop the service, which allows the program to clean up resources. We strongly recommend that you use the AnQiCMS provided scripts first.stop.shScript to stop the service.

Ifstop.shThe script did not work, or your deployment method did not provide such a script, you can choose to usekill -9Command to force quit the process. Note,kill -9The process will be terminated forcibly, without giving the process a chance to clean up normally, therefore it is usually used as a last resort:

kill -9 7621

Among them7621That is where you arelsofThe process PID found in the output. After executing this command, the process will be terminated immediately. To confirm again, you can run it again.lsof -i:8001. If there is no output at this time, it means that the process has successfully terminated and the port has been released.

Why is a clean shutdown crucial?

Successfully stopping and releasing the port is not just to avoid conflicts, it is also the key to maintaining server health and ensuring the stable operation of AnQiCMS. A clean stop operation can prevent:

  • Port conflict:Avoid the newly started service from failing due to the port being occupied.
  • Resource leak:Ensure that AnQiCMS releases all occupied memory and other system resources.
  • Data corruption:Graceful shutdown allows AnQiCMS to complete the ongoing data operations, reducing the risk of data corruption.
  • System stability:Avoid zombie processes or other abnormal states, maintain the cleanliness and stability of the server environment.

MasterlsofCommand, allowing you to operate AnQiCMS daily like an experienced detective, quickly locate and resolve port occupation issues, ensuring smooth website operation without hindrance.


Frequently Asked Questions (FAQ)

Q1: I have run AnQiCMS'sstop.shscript, whylsofis still showing that the port is occupied?A1: How many possibilities are there. First, the script may have failed to terminate the process, for example, due to insufficient permissions or slow response from the process.The process of AnQiCMS may have terminated, and another service quickly occupied the same port.Moreover, in some extreme cases, a 'zombie process' may occur, although the process itself has stopped executing, it still remains in the process table at this timekill -9It may be the only valid cleaning method. You can try checking again after a while or use it directly.kill -9Command cleaning.

Q2:kill -9Is the command safe? Is there a gentler way to stop AnQiCMS?A2:kill -9It is a强制终止命令,it will not give the process any opportunity to clean up or save data, therefore there is a risk of data loss or corruption.In most cases, it is recommended to use a milder approach. For passingstart.sh/stop.shAnQiCMS instance started by the script,stop.shThe script is a gentler, recommended way. It usually sends a SIGTERM signal to the process, allowing the program to clean up and exit gracefully. Only whenstop.shInvalid, or consider using it only when the process does not respond for a long timekill -9.

Q3: If I do not know the specific port where the AnQiCMS project is running, how can I find it?A3: Port configuration of AnQiCMS

Related articles

What problems may occur if AnQiCMS is restarted immediately after stopping?

## AnQi CMS: What operational risks may be hidden in a hasty restart?As an expert in website operation for many years, I am well aware that each CMS system has its unique operational mechanism, AnQiCMS is no exception.AnQiCMS with its high-performance, modular design based on the Go language and rich enterprise-level features has won the favor of many operators.However, even such an efficient system, if an improper restart operation is performed immediately after stopping, it may also埋下 significant operational risks.

2025-11-06

What related information will the log file of AnQiCMS record after the service stops?

As an experienced website operations expert, I am well aware of the importance of system logs in maintaining website stability and troubleshooting.It is like a black box of an airplane, recording every detail of system operation, especially when the service stops unexpectedly, the log files are our 'golden clues' for quickly locating problems and restoring services.AnQiCMS as an enterprise-level content management system developed based on the Go language has a rigorous and efficient logging mechanism that can provide us with rich information.

2025-11-06

How to judge whether the stop operation of AnQiCMS is 'graceful' or 'forceful'?

As an experienced website operation expert, I am well aware of the powerful strength of AnQiCMS in the content management field.It is built on the Go language, creating a highly efficient, customizable, and easy-to-expand platform.In our daily operations, the startup and shutdown operations of core systems like AnQiCMS are not as simple as running or closing, behind which lies the philosophy of 'elegant' and 'forced', which directly relates to the integrity of website data, the stability of user experience, and the rational release of system resources.

2025-11-06

How to ensure a safe interruption of ongoing operations (such as collection) when AnQiCMS stops?

As an experienced website operation expert, I know that every system start-up and shutdown operation affects the stability and data security of the site.Especially for tasks like content collection that require long-running operations and involve data writing, how to ensure safe interruption when stopping the CMS, to avoid data corruption or leaving behind zombie processes, this is indeed a concern for operators.AnQiCMS (AnQiCMS) is an efficient content management system developed based on the Go language, which considered these issues from the beginning of its design.

2025-11-06

Where is the default directory of AnQiCMS's `start.sh` and `stop.sh` scripts?

As an experienced website operations expert, I know that a high-efficiency and stable content management system (CMS) is crucial for the successful operation of a corporate website.AnQiCMS with its lightweight and efficient Go language stands out among many CMS systems, providing us with a solid foundation.In daily system maintenance and troubleshooting, the `start.sh` and `stop.sh` service management scripts of AnQiCMS play a core role.

2025-11-06

What negative impacts will there be on the SEO spider crawling the website after the AnQiCMS service is stopped?

As an experienced website operations expert, I know that every CMS system is crucial for the SEO performance of a website, especially systems like AnQiCMS (AnQiCMS) that integrate a large number of SEO-friendly features from the very beginning.It not only provides the efficiency of content management, but also secures a place for the website in search engines through a series of advanced SEO tools.

2025-11-06

How to temporarily disable some features of AnQiCMS without completely stopping it?

## Flexible Control: Disabling Specific AnQiCMS Features Without Interrupting Service As an experienced website operations expert, I know that in our daily work, we often need to fine-tune website features, sometimes to test new modules, sometimes to temporarily disable certain services that are no longer applicable, or to maintain and upgrade without affecting core business.How to temporarily disable some functions of AnQiCMS without completely stopping it?

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