How to modify the `start.sh` script so that it can still work normally after the AnQiCMS process name changes?

Calendar 👁️ 72

As an experienced CMS website operation personnel in an enterprise, I am well aware of the importance of maintaining the stable operation of the system, especially in a variable application environment.AnQi CMS is favored by our operations team for its efficiency in Go language and ease of deployment.However, in daily operations, especially when it involves multi-site deployment or personalized configuration, there may be a need to adjust the core startup script to adapt to the new process naming rules.

Understandingstart.shThe core function of the script

start.shThe script is a key file for implementing automatic check and startup of AnQi CMS in the Linux environment.Its main responsibility is to regularly check if the security CMS process is running, and if it finds that the process does not exist, it will automatically start it.This mechanism ensures the continuous availability of the website service, even if the server restarts unexpectedly or the process crashes, it can recover quickly.BINNAME) and the program path (BINPATH), and throughps -ef | grepcommand to find matchingBINNAMErunning process.

The analysis of the scenario where the process name of AnQi CMS changes

When AnQi CMS is installed in standard mode, its executable file is usually namedanqicms.However, in certain operational scenarios, we may change this default process name.taobaokeoranqicms_dev. The document also clearly states that users can configureanqicmsRename the file to a new different filename.In addition, some customized deployments or future version updates may also introduce different process naming conventions.start.shThe script will not be able to correctly identify or start a new process, leading to service interruption.

modifystart.shthe script to adapt to the new process name

To ensurestart.shThe script still works normally after the process name of AnQi CMS is changed, and we need to modify it accordingly so that it can recognize the new executable file name. This modification process mainly focuses on defining the binary file name variable in the script and the one used to locate the process.grepCommand parameters.

First, locate tostart.shin the fileBINNAMEA variable. This variable stores the name of the executable file of Anqicms. If we rename theanqicmsBinary file totaobaoke, then we need toBINNAME=anqicmsis modified toBINNAME=taobaoke.

Next, the script usesps -ef | grep '\<anqicms\>'commands to find processes. Here is\<anqicms\>a regular expression used to match the full process name preciselyanqicms. If the process name has changed, thisgrepThe pattern must be updated accordingly. For example, if the new process name istaobaoke, then this command should be modified tops -ef | grep '\<taobaoke\>'. It is important to note thatstop.shthe script also contains the samegrepCommand used to terminate the process, therefore, the same modification is also required. EnsureBINNAMEvariables andgrepThe name in the pattern should be consistent, which is the key to the normal operation of the script

Special considerations in a multi-site environment

When deploying multiple AnQi CMS instances on the same server, each instance should have its own installation directory, configuration files, database, and most importantly - a unique binary filename. This means that each AnQi CMS instance needs its own independentstart.shandstop.shscript. Each script inBINPATHThe variable should point to the installation path of the corresponding instance,BINNAMEvariables andgrepThe pattern should match the unique process name of the instance. Such configuration can effectively isolate different instances, ensuring they do not interfere with each other and can be correctly managed by their respective scripts.

Verify the validity of the script modification

Donestart.shandstop.shAfter the modification of the script, it is imperative to thoroughly test it to verify its validity. First, try to manually execute the newstart.shScript, observe whether the Anq CMS process has started successfully. It can beps -ef | grep 新进程名used to confirm whether the process exists and is running normally. Then, teststop.shCan the script correctly terminate the process. Finally, configure the modified script to the scheduled task (such ascrontab), wait for the scheduled task to execute periodically, and checkcheck.logandrunning.logFile, ensure that the script can automatically detect and maintain the service status.

Summary

Yesstart.shAdjust the script appropriately to adapt to the change in the safe CMS process name, which is a necessary step to ensure system stability. By understanding the working principle of the script, make accurate modificationsBINNAMEvariables andgrepWe can effectively manage the security CMS service by fine-tuning the configuration in a multi-site environment, thus providing reliable backend support for the website.


Frequently Asked Questions (FAQ)

1. I have renamed the binary file of Anqi CMS, butstart.shThe script still cannot start the service, why is that?

In most cases, this is because you may have only modifiedstart.shin the scriptBINNAMEVariables, but forgot to synchronize the updateps -ef | grepThe process name matching pattern in the command. These two places must be consistent so that the script can correctly identify and search for new processes. Moreover, ifstop.shThe script also has the same issue, it will not be able to terminate old or incorrect processes. It is recommended to carefully check all the involved in both scripts.anqicmsThe location of the name, make sure they have all been changed to the new binary filenames.

2. Besides modificationBINNAMEandgrepThe pattern, are there any other configurations to pay attention to after changing the process name?

If you are deploying multiple AnQi CMS instances on a server and have changed the process names for each instance, then you also need to make sure that each instance'sconfig.jsonin the fileportThe configuration is unique, and the Nginx or other reverse proxy configuration has also been updated to point to the correct port. At the same time, each instance'sBINPATHVariables should also point to their respective installation directories to avoid data confusion or conflicts between different instances. These are key configurations to ensure the independent and stable operation of multiple instances.

3. If I don't want to manually modify the script every time to change the process name, is there a more general method to manage the AnQiCMS process?

Although the Anqi CMS'sstart.shScript design is simple and efficient, but in some advanced scenarios, you may want to use a more generic process management method. For example, you can usesystemda service management tool to create a service unit file.systemdAllow you to define the service startup command, working directory, user, dependencies, etc., without directly modifyingstart.sh. Even if the process name changes, as long as the startup command in the service unit file points to the correct binary file,systemdCan manage it.Another method is to use a more general process identification method in the script, such as by listening to ports to determine if the AnQiCMS service is running, but this method is usually not as precise and reliable as directly matching the process name.

Related articles

If the `BINPATH` setting in the AnQiCMS startup script is incorrect, what PID-related issues may arise?

As an experienced AnQiCMS website operator, I know that every detail of the startup script may affect the stable operation of the system.In the daily operation and maintenance of AnQiCMS, the `BINPATH` variable in the startup script plays a vital role, indicating the storage path of the AnQiCMS executable files.Once this path is set incorrectly, a series of issues related to the Process ID (PID) will arise, directly affecting the startup, monitoring, and management of the AnQiCMS service.

2025-11-06

How does the `crontab` task automatically restart AnQiCMS after the process terminates unexpectedly?

As an expert well-versed in the operation of AnQiCMS, I know the importance of stable system operation for content management.AnQiCMS as an enterprise-level content management system developed based on the Go language, its high performance and reliability are one of its core advantages.Even if the system itself is robustly designed, but the server environment is complex and variable, the situation where the process is unexpectedly terminated may still occur.How to ensure that AnQiCMS can quickly recover services in this case is a key point that website operators must pay attention to

2025-11-06

The `lsof -i:{port number}` command is used for port conflict troubleshooting in AnQiCMS, what is its specific function?

As an experienced CMS website operation person in an information security company, I am very clear about the various technical challenges I encounter in daily maintenance, especially those related to server environment configuration and system stable operation.Among them, port conflict is a common problem that also directly affects the availability of services.When your AnQiCMS website suddenly becomes inaccessible, or you encounter obstacles when deploying a new site, the `lsof -i:{port number}` command often becomes the key to quickly locate and solve the problem.

2025-11-06

When AnQiCMS default port is occupied, how to find and terminate the conflicting process through PID?

HelloAs a senior security CMS website operator, I fully understand the difficulties encountered in the operation when technical problems arise, especially when it affects the normal operation of the website.Port occupancy is one of the common but relatively easy problems to solve.When the default running port of AnQi CMS is occupied by other programs, the system will fail to start normally.Below, I will explain in detail how to locate and terminate these conflicting processes to ensure your safe CMS website goes live.

2025-11-06

AnQiCMS is deployed on Baota Panel, what is the difference between PID monitoring of Go projects and manual scripts?

As an experienced security CMS website operator, I know that the stable operation of the website is the foundation for the efficient publication and optimization of content.The choice of deployment and process management methods for systems like AnQiCMS, which are developed based on the Go language, directly affects the reliability and operation and maintenance efficiency of the system.Today, let's delve into the similarities and differences between the PID monitoring mechanism of the AnQiCMS Go project and the manual maintenance script when deployed on Baota panel.

2025-11-06

When encountering AnQiCMS process zombie (Zombie Process), can the PID management script solve it?

AnQiCMS is an enterprise-level content management system developed based on the Go language, which has won the favor of many small and medium-sized enterprises and content operation teams with its high efficiency, customizable and scalable features.As an experienced website operator, I am well aware of the importance of stable server operation for content platforms.In daily operation and maintenance, we occasionally encounter some abnormal server process situations, among which a "zombie process" is one of them.

2025-11-06

How to ensure that only the target AnQiCMS process is terminated by the stop script, not other同名 processes?

As a website operator who deeply understands the operation of AnQiCMS, I know the importance of precise control over website services.In routine maintenance, stopping or restarting services is a common operation, but ensuring that only the target process is terminated and not inadvertently affecting unrelated or同名 processes is a challenge that technical personnel must face.AnQiCMS designed its stop script with full consideration of this requirement, achieving precise identification and termination of specific AnQiCMS processes through the clever use of Linux command-line tools and clear naming conventions.

2025-11-06

When the AnQiCMS process starts, which information in the `running.log` file is helpful for PID debugging?

As a website operator who deeply understands the operation of AnQiCMS, I know that every system file hides valuable information, especially when the system is abnormal, the log file is the key to troubleshooting.When the AnQiCMS process starts, the content recorded in the `running.log` file is crucial for debugging PID (process ID) and troubleshooting startup issues.

2025-11-06