As a website operator deeply familiar with AnQiCMS, I am well aware of the importance of system stable operation and efficient problem-solving for content management.When AnQiCMS is running and an exception occurs, or when it is necessary to gain a deeper understanding of its internal workflow, obtaining detailed debugging information is a crucial step.start.shScript as the startup entry of AnQiCMS under the Linux environment, which is the key part we modify to obtain more debugging information.

Understandingstart.shThe initial function of the script

In AnQiCMS deployment,start.shThe script is responsible for checking the status of the AnQiCMS process and starting its main program. Through the documentation, we learn that its core logic includes determining whether AnQiCMS is running, and if not, it starts throughnohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &This command is used to start the program. The meaning of this command is that it runs in the background (through)nohup) the executable file of AnQiCMS, and redirects standard output and standard error ()$BINPATH/$BINNAME) to2>&1)all redirected torunning.login the file. This means that all information directly output by the AnQiCMS program to the console will be recorded in this log file.

However, for deeper debugging needs, simply capturing standard output and standard error may not be enough. Many Go language applications, including content management systems like AnQiCMS, typically support different log levels, such asinfo/warn/errorand the most commonly needed when debuggingdebugortracelevel. To obtain "more detailed debugging information", it is often necessary to indicate that the AnQiCMS program itself should run at a higher log level.

Methods to enable detailed debugging information

AnQiCMS as an application developed in Go language, the detail level of its log output can usually be controlled by the following common methods:

First, many applications will respond to specificenvironment variables. For example, you can setANQICMS_DEBUG=trueorLOG_LEVEL=debugThis environment variable tells the program to output more details. These environment variables need to be set before the program starts.

Secondly, some programs will acceptcommand-line argumentsControl the log level. For example, add after the startup command.--debugor--verboseSuch a flag.

Moreover,Configuration fileIt is also a common way to control the behavior of the application. AnQiCMSconfig.jsonThe file is used to configure ports and other basic information, theoretically it can also include log level settings. But according to the provided document,config.json主要用于模板相关的配置,并未明确指出其支持日志级别调整。因此,我们需要将重点放在前两种通过 English 方法的脚本直接修改上。start.sh脚本直接修改的方法上。

Modifystart.shScript to get detailed debug logs

To record more detailed debug information when AnQiCMS starts, we need to modifystart.shScript, add the corresponding control parameters when executing the AnQiCMS program.Here we will introduce two methods of modification based on environment variables and command line arguments, and you can try according to the parameters supported by AnQiCMS.At the same time, in order to avoid confusion between debug logs and regular runtime logs, it is recommended to output debug information to a separate log file.

The following is the modificationstart.shSteps of the script:

First, find the AnQiCMS installation directory on your serverstart.shfile. Usually, this file will be located/www/wwwroot/your_domain/start.shpath (depending on your actual installation path).

Open with text editorstart.shFor example, files,vi start.shornano start.sh.

Find the line in the script that starts the AnQiCMS core program. It will roughly look like this:cd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &

Now, we will modify this line based on different debugging needs:

Method one: Enable detailed logging by setting the environment variable

If AnQiCMS supports controlling the log level through environment variables (such asANQICMS_LOG_LEVEL=debug),You can set this environment variable before executing the command. The modified startup command may look like this:

#!/bin/bash
### check and start AnqiCMS
# author fesion
# the bin name is anqicms
BINNAME=anqicms
BINPATH=/www/wwwroot/anqicms # 请根据您的实际路径修改

# check the pid if exists
exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |wc -l`
echo "$(date +'%Y%m%d %H:%M:%S') $BINNAME PID check: $exists" >> $BINPATH/check.log
echo "PID $BINNAME check: $exists"
if [ $exists -eq 0 ]; then
    echo "$BINNAME NOT running"
    # --- 添加或修改以下行以启用更详细的调试日志 ---
    export ANQICMS_LOG_LEVEL="debug" # 假设 AnQiCMS 响应 ANQICMS_LOG_LEVEL 环境变量
    # 或者尝试更通用的 LOG_LEVEL 环境变量
    # export LOG_LEVEL="debug"

    # 将详细日志输出到专门的 debug.log 文件,方便区分
    cd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/debug_running.log 2>&1 &
fi

Here, we useexport ANQICMS_LOG_LEVEL="debug"Using an (or similar variable) to try to enable debug mode. At the same time, we will change the log file todebug_running.logIn order to separate debug information from regular runtime logs, which will be very helpful during later analysis.

Method two: Enable detailed logging by passing command line parameters

If AnQiCMS supports controlling the log level through command line arguments (for example--debugor--log-level debug),You can pass these parameters to the executable file when you run the command. The modified startup command may look like this:

#!/bin/bash
### check and start AnqiCMS
# author fesion
# the bin name is anqicms
BINNAME=anqicms
BINPATH=/www/wwwroot/anqicms # 请根据您的实际路径修改

# check the pid if exists
exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |wc -l`
echo "$(date +'%Y%m%d %H:%M:%S') $BINNAME PID check: $exists" >> $BINPATH/check.log
echo "PID $BINNAME check: $exists"
if [ $exists -eq 0 ]; then
    echo "$BINNAME NOT running"
    # --- 添加或修改以下行以启用更详细的调试日志 ---
    # 假设 AnQiCMS 响应 --debug 命令行参数
    # cd $BINPATH && nohup $BINPATH/$BINNAME --debug >> $BINPATH/debug_running.log 2>&1 &

    # 或者假设 AnQiCMS 响应 --log-level debug 命令行参数
    cd $BINPATH && nohup $BINPATH/$BINNAME --log-level debug >> $BINPATH/debug_running.log 2>&1 &
fi

Please note that you may need to refer to the official development documentation or source code of AnQiCMS to confirm the specific supported environment variables or command-line parameter names.Because the provided document does not explicitly state how AnQiCMS controls its internal log level.As an operation person, it is very important to maintain a mindset of exploration and verification when trying these general methods.

After modification, save.start.shFile. To make the modification take effect, you need to first stop the currently running AnQiCMS instance (if it exists), and then re-execute itstart.shthe script to start AnQiCMS.

Stop AnQiCMS command example (please adjust according to your)stop.shscript path and content): ./stop.sh

Start AnQiCMS command example: ./start.sh

After starting, you can viewdebug_running.logFile to get detailed debugging information generated by AnQiCMS. For example:tail -f $BINPATH/debug_running.log.

Remember that keeping detailed debug logs enabled for an extended period in a production environment may affect system performance and may expose some sensitive information. Therefore, it is recommended that you turn off detailed debug logs after completing problem troubleshooting.start.shScript restored to the original configuration, or at least the log level is adjusted back to normal mode.


Common Questions and Answers (FAQ)

Q: Will enabling detailed debug logs affect the performance of AnQiCMS?

答:是的,长时间开启详细调试日志通常会影响AnQiCMS的运行性能。Because the program needs to spend additional time and resources to generate, format, and write a large amount of log information, this will increase the overhead of CPU, memory, and disk I/O.After solving the problem, it is recommended that you promptly turn off the detailed log mode to ensure the system's performance.

问:If I modifystart.shscript but AnQiCMS still does not output detailed logs, what should I do?

答:If in the modificationstart.shAfter the script and restart of AnQiCMS, you still do not see more detailed output in the log file, which may mean that the AnQiCMS application itself did not respond to the environment variables or command line parameters you tried to set.In this case, you should refer to the latest official development documentation of AnQiCMS, or look for specific instructions on how to enable more detailed logs in the AnQiCMS community forum or GitHub repository.