As a long-term practitioner of operating the AnQiCMS website, I am well aware of the importance of system stability and efficient deployment for website operation.In daily work, server port occupation is a common but often overlooked issue.start.shHow to respond, and how we as operations personnel should understand and handle such situations.
AnQiCMS as an enterprise-level content management system based on the Go language, its deployment process is relatively simple and efficient. Under the Linux environment, we usually usestart.shSuch a startup script is used to manage the start and stop of AnQiCMS services.The main responsibility of this script is to check the running status of the AnQiCMS process and try to start the executable file of AnQiCMS when the service is not running.ps -ef | grepcommand to find the process namedanqicmsIf the process is not found, the command will be executednohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &command to start the AnQiCMS program in background mode.
However,start.shThe design principle of the script is process management, rather than configuration management or dynamic adjustment of the runtime environment.It does not include any built-in logic to detect whether the port used by the AnQiCMS application has been occupied.start.shThe script itself cannot detect port conflicts and cannot automatically switch to other available ports when a port is occupied, nor can it provide clear prompts to the user.
The port configuration of AnQiCMS is static, mainly through the project root directory.config.jsonFile is set.By default, AnQiCMS will try to use port 8001.config.jsonFiles, specify a different, unused port for each AnQiCMS instance.This configuration method gives the operation personnel a high degree of control, but also requires that we be vigilant about the port usage when deploying and maintaining.
Therefore, when the AnQiCMS program attempts to start, and the default port specified in its configuration file (such as 8001) is already occupied by another service,start.shThe script will execute the startup command according to its established logic. But at this moment, the AnQiCMS application itself will fail to start due to inability to bind to the specified port. In this case, start.shThe script will not output a prompt such as 'Port is already occupied, please check' or try to find the next available port for binding. For operators, this may manifest as the service appearing to start but being inaccessible, or in the program'srunning.logError message indicating port binding failure was found.
To resolve the issue of AnQiCMS not starting due to port occupation, we must take manual intervention measures. First, we need to run system commands such aslsof -i:{端口号})To confirm which process is using the target port. After finding the process ID that is using the port, you can choose to terminate the process or modify AnQiCMS'sconfig.jsonFile, change its port to another unused port. After modifying the configuration, run it againstart.shScript, AnQiCMS can start normally and provide services.
In summary, the value of AnQiCMS'sstart.shThe startup script is an efficient process manager, responsible for ensuring that the AnQiCMS service runs continuously in the background.But in this specific scenario of port occupation, it does not have the ability to perform intelligent detection, automatic switching, or provide user prompts.The operation staff should be clear about this mechanism so that they can quickly locate and take the correct solution when encountering relevant issues, ensuring the normal operation of the website.
Common Questions and Answers (FAQ)
1. How is the service port of AnQiCMS configured? Can I modify it?
AnQiCMS's service port is mainly configured through the root directory of the projectconfig.jsonFile configuration is performed, the default port is usually 8001.You can manually edit this file to change the port number, ensuring that it does not conflict with other services on the server.After changing the port, you need to restart the AnQiCMS service to make the new configuration take effect.
2.start.shWill the script tell me which port is occupied? Or will it automatically try other ports?
No.start.sh脚本是一个进程管理脚本,它的主要职责是检查 AnQiCMS 进程是否在运行,并在未运行时尝试启动它。It does not include logic for port detection, automatic switching, or providing specific port occupation hints.When the port is occupied and AnQiCMS cannot start, you need to manually investigate the cause.
3. If AnQiCMS cannot be accessed after startup, how can I check if it is a port occupation issue?
If you cannot access AnQiCMS after it starts, you should check firstrunning.logfile, AnQiCMS program may output port binding failure error information in this log. At the same time, you can use it in the Linux environment.lsof -i:{端口号}commands (for examplelsof -i:8001To view which process is using the port that AnQiCMS is trying to use, locate the process that is occupying it. Once found, you can choose to terminate the process or modifyconfig.jsonConfiguration of ports in the file, then restart AnQiCMS.