How does the Baota panel's Go project deployment method differ from the PID management mechanism of the AnQiCMS built-in script?
AnQi CMS is an enterprise-level content management system developed based on the Go language, which is favored by 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 the AnQiCMS Go project on the Baota panel and analyze the similarities and differences in its PID management mechanism and the scripts provided by AnQiCMS.
The process of deploying AnQiCMS Go project on Baota panel
Deploy AnQiCMS Go project on Baota panel, especially in version 7.9.3 and above, the operation process has been greatly simplified and optimized, fully utilizing the advantages of Baota panel's native support for Go language projects.
Firstly, you need to log in to Baota panel and ensure that the Docker service is installed (if you need to deploy using Docker). 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 newanqicms.comDirectory, upload and unzip the AnQiCMS Linux installation package to this directory.
Next, navigate to the "Website" function area on the left menu of the Baota panel, click the "Go project" option.Here, you will see the 'Add Go project' button. Clicking it will open a configuration window where you need to fill in the following key information:
- Project executable file:Specify the complete path to the AnQiCMS executable file, for example
/www/wwwroot/anqicms.com/anqicms. - Project name:Name a recognizable name for your AnQiCMS instance, such as
AnQiCMS_Main. - Project port:Set the port that the AnQiCMS program listens to, 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 the command:Please fill in the full path of the AnQiCMS executable file again, the Baota panel will use this command to start your Go application.
- Run user:Generally, it is chosen
wwwUser, to ensure that the program has the appropriate permissions. - Boot up:It is strongly recommended to check this option, so that the AnQiCMS service will automatically start after the server restarts, without manual intervention.
- Bind domain:Enter the domain name you have resolved to the server.
After completing the above configuration and clicking submit, the Baota panel will automatically handle the deployment and startup of the AnQiCMS project.Later, you need to configure reverse proxy for the domain in the "Website" list of the Baota panel.Click the "Settings" of the corresponding domain name, go to the "Website Directory" and set the running directory to/public. Add proxy rules in the 'Reverse Proxy' to forward your domain traffic to the internal port that AnQiCMS is listening on (for examplehttps://en.anqicms.com)。Finally, by visiting your domain name through the browser, you can enter the AnQiCMS initialization installation interface and complete the database configuration and administrator account settings.
The analysis of PID management mechanism: Differences and similarities between Baota panel and AnQiCMS built-in scripts
The operation of AnQiCMS cannot do without 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 consistent with the one built into AnQiCMS.start.shandstop.shThe script has significant similarities and differences.
The Baota panel's PID management mechanism
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 the AnQiCMS process.
In this mode, the Baota panel will:
- Automatically monitor processes:The Baota panel will continuously check the running status of the AnQiCMS process.If a process terminates unexpectedly, it will automatically try to restart according to the configuration (such as the "boot start" option) to maintain the continuity of the service.
- Unified scheduling management:Users can easily perform operations such as starting, stopping, and restarting AnQiCMS through the graphic interface of the Baota panel.These operations are converted to corresponding system commands by the Baota panel, 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 running environments for different Go projects to avoid resource contention.
- Log integration:The Baota panel collects the runtime logs of Go projects and provides a unified view and management interface, which is convenient for users to troubleshoot issues.
In short, the Baota panel actually creates a regulated service for AnQiCMS when deploying a Go project.The identification and lifecycle management of PID is entirely handled by the backend service of Baota panel, it may not explicitly create and maintain PID files, but instead tracks Go projects through the system process table.
AnQiCMS built-in script (start.sh/stop.shThe PID management mechanism
Provided by AnQiCMSstart.shandstop.shThe script is designed for users who have not used Baota panel or other advanced process managers, or manually deployed AnQiCMS in the 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 process status:It uses
ps -ef | grep '\<anqicms\>' | grep -v grep | wc -lsuch command combinations to find the number of running processes namedanqicms.grep '\<anqicms\>'Used to match the process name accurately,grep -v grepexcludedgrepits own process,wc -lthen count the number of lines. - Start the process:If detected,
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 that 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
pscommands 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 process's PID.awk '{printf $2}'Used to extract the PID column from the process list. - Terminate the process:If the PID is found, the script will use
kill -9 $existscommand to forcibly terminate the process.
Bycrontabcooperatestart.shA script that 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.
Summary of similarities and differences
Similarities:
- Core Objective:Both strive to ensure the continuous operation of the AnQiCMS application and start or restart it as necessary.
- Basic Operations:Finally, the service is started by executing the AnQiCMS executable file compiled in Go language.
Differences:
- Management entity:The Baota panel manages the AnQiCMS process through its built-in service management module (such as systemd integration), providing a high-level abstraction and visual interface. The AnQiCMS自带脚本 is a direct shell script, through
crontabExecuted by the operating system itself. - Robustness and automation level:The Baota panel management mechanism is more robust and automated. It can more accurately monitor process status, handle various abnormal situations (such as port occupation, process僵死), and provide detailed logs and alarm functions.The robustness of the built-in script is relatively low, mainly relying on timed checks and brute force
kill -9Limited in handling complex exceptions. - PID recognition method:The Baota panel usually tracks the process PID in a more fundamental and systematic way when deploying Go projects. And
start.sh/stop.shscripts go throughgrepandawkParsingps -efThis output method may have certain limitations and inaccuracy in extreme cases (such as server overload causingpsslow command response or process name conflicts. - User interaction:Baota panel provides a graphical interface for operations such as startup, stop, restart, etc., providing a better user experience. The built-in scripts require users to manually execute or configure through the command line.
crontabScheduled task. - Multi-site management:The 'Go project' feature of Baota panel can elegantly manage multiple AnQiCMS instances, each instance can bind different ports and domains, which are scheduled by the panel. To manage multiple sites with the built-in script, a separate set of scripts needs to be copied for each site