AnQi CMS is an enterprise-level content management system developed based on the Go language, which is favored by many small and medium-sized enterprises and content operation teams for its simple deployment, security, and efficiency.In the Linux server environment, Baota Panel, as a widely popular server operation and maintenance tool, provides great convenience for the deployment of AnQiCMS.This article will discuss in detail how to deploy AnQiCMS Go project on Baota panel, and analyze the similarities and differences in PID management mechanism and the built-in scripts of AnQiCMS.
Deploy the AnQiCMS Go project on the Baota panel
Deploy AnQiCMS Go project on the Baota panel, especially in version 7.9.3 and above, the operation process has been greatly simplified and optimized, fully utilizing the native support advantage of the Baota panel for Go language projects.
Firstly, you need to log in to the Baota panel and ensure that the Docker service is installed (if you want to deploy using the Docker method). If you choose to directly deploy the executable file of AnQiCMS to the server, you need to create a dedicated directory for AnQiCMS in the file management, for example, in/www/wwwroot/Create a new folder.anqicms.comUpload the Linux installation package of AnQiCMS to this folder and unzip it.
Next, navigate to the "WebsiteHere, you will see the 'Add Go Project' button.
- Project executable file:Specify the full path of the AnQiCMS executable file, for example
/www/wwwroot/anqicms.com/anqicms. - Project Name:Give your AnQiCMS instance a recognizable name, such as
AnQiCMS_Main. - Project Port:Set the port that the AnQiCMS program listens on, the default is usually
8001. If you plan to deploy multiple AnQiCMS instances, each instance needs to be configured with a non-conflicting port. - Execute command:Please fill in the complete path of the AnQiCMS executable file again, Baota panel will use this command to start your Go application.
- Run as user:Generally chosen
wwwUsers, to ensure that the program has the appropriate permissions. - Boot up:Strongly recommend checking this option, so that the AnQiCMS service will automatically start after the server restarts, without manual intervention.
- Domain binding:Fill in the domain name you have parsed to the server.
After completing the configuration and clicking submit, the Baota panel will automatically handle the deployment and startup of the AnQiCMS project.Then, you need to configure reverse proxy for the domain in the 'Website' list on the Baota panel./publicThen add proxy rules in the "Reverse Proxy" to forward your domain traffic to the internal port that AnQiCMS is listening on (for example,http://127.0.0.1:8001)。Finally, by visiting your domain through the browser, you can enter the initialization installation interface of AnQiCMS and complete the database configuration and administrator account settings.
Analysis of PID management mechanism: Differences and similarities between Baota panel and AnQiCMS built-in scripts
The operation of AnQiCMS relies on process management to ensure its stability and availability. When deploying the AnQiCMS Go project in the Baota panel environment, its PID (Process ID) management mechanism is different from the one built-in to AnQiCMS.start.shandstop.shThe script has significant similarities and differences.
The PID management mechanism of the Baota panel
When you deploy AnQiCMS through the 'Go project' feature of Baota panel, Baota panel takes on the main process management responsibilities.It utilizes the underlying process management tools of the operating system (such as Systemd, Supervisor, or other daemon management schemes on Linux) to monitor, start, and stop AnQiCMS processes.
In this mode, the Baota panel will:
- Automatically monitor processes:The Baota panel will continuously check the running status of the AnQiCMS process.If the process terminates unexpectedly, it will automatically attempt to restart according to the configuration (such as the 'Boot' option) to maintain the continuity of the service.
- Unified scheduling and management:Users can directly execute operations such as starting, stopping, and restarting AnQiCMS through the graphical interface of the Baota panel.These operations are converted by the Baota panel into corresponding system commands to execute, and users do not need to interact directly with the underlying process commands.
- Isolation and Resource Management:The Baota panel can better manage the resource usage of AnQiCMS processes, such as allocating independent runtime environments for different Go projects, avoiding resource contention.
- Log integration:The Baota panel collects the runtime logs of Go projects and provides a unified view and management interface for easy problem troubleshooting by users.
In brief, the Baota panel actually creates a regulated service for AnQiCMS when deploying Go projects.The identification and lifecycle management of the PID is completely handled by the backend service of Baota panel, it may not explicitly create and maintain the PID file, but instead tracks Go projects through the system process table.
AnQiCMS comes with its own script (start.sh/stop.shThe PID management mechanism )
Provided by AnQiCMSstart.shandstop.shThe script is designed for users who do not use the TengAdmin panel or other advanced process managers, or manually deploy AnQiCMS in a command-line environment.These scripts interact directly with the operating system via shell commands to implement basic process management functions.
start.shThe main logic of the script is:
- Check the process status:It uses
ps -ef | grep '\<anqicms\>' | grep -v grep | wc -lSuch a command combination to search for a process namedanqicmsthe number of running processes.grep '\<anqicms\>'Used for precise matching of process names,grep -v grepUsed to excludegrepits own process,wc -lCount the number of lines. - Start the process:If it detects
anqicmsThe process is not running (i.e.,exists -eq 0), the script will switch to the installation path of AnQiCMS (BINPATH),then usenohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &Command to start the program.nohupEnsure the program continues to run even after the user exits the terminal.>> $BINPATH/running.log 2>&1Redirect the standard output and standard error of the program torunning.logfile.&Run the program in the background.
- Do not create a PID file:It is worth noting that these scriptsnoneExplicitly create and manage PID files. They are completely dependent on
psCommand to find PID by process name.
stop.shThe logic of the script is:
- Find PID:It uses
ps -ef | grep '\<anqicms\>' | grep -v grep | awk '{printf $2}'to findanqicmsthe PID of the process.awk '{printf $2}'Used to extract the PID column from the process list. - Terminate process:If the PID is found, the script will use
kill -9 $existscommand to force terminate the process.
Passcrontabwithstart.sh[en]The script can implement a simple self-start and guard function to check and start AnQiCMS every minute, ensuring that the service can recover automatically after a crash.
[en]Summary of similarities and differences
[en]Similarities:
- Core Objective:Both are committed to ensuring the continuous operation of the AnQiCMS application and to start or restart it when necessary.
- Basic Operations:Ultimately, the service is started by executing the AnQiCMS executable file compiled in Go language.
Differences:
- Management subject:The Baota Panel manages AnQiCMS processes through its built-in service management module (such as Systemd integration), providing a high-level abstraction and visual interface. AnQiCMS comes with direct shell scripts.
crontabExecuted by the operating system itself in such a way. - Robustness and automation level:The management mechanism of the Baota panel is more robust and automated.It can more accurately monitor the process status, handle various exceptions (such as port occupation, process zombies), and provide detailed logs and alarm functions.
kill -9Limited in handling complex exceptions. - PID identification method:The Taota面板 usually tracks the process PID in a more low-level and systematic way when deploying Go projects.
start.sh/stop.shscripts go throughgrepandawkanalysisps -efThe output in this way may have certain limitations and inaccuracy in some extreme cases (such as excessive server load)psSlow command response, or process name conflict may exist. - User Interaction:The Baota panel provides a graphical interface for operations such as start, stop, restart, etc., offering a better user experience. Scripts are required to be manually executed or configured via the command line by the user.
crontabSchedule task. - Multi-site management:The "Go project" feature of the Baota panel can elegantly manage multiple AnQiCMS instances, each instance can be bound to different ports and domains, and the panel unifies scheduling. To manage multiple sites with the built-in script, it is necessary to replicate a set for each site.