apolloconfig / apollo

Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.
https://www.apolloconfig.com
Apache License 2.0
29.18k stars 10.21k forks source link

脚本启动与停止的问题 #5142

Closed Fivemeters closed 6 months ago

Fivemeters commented 6 months ago

请问下shell脚本中的 ./###.jar start 这种启动方式,我看spring boot启动的时候日志不会打印到控制台,后台在运行,也没有加nohup命令,这个是怎么做到的,是怎么配置的。

dosubot[bot] commented 6 months ago

To achieve the behavior where a Spring Boot application runs in the background without printing logs to the console, without using nohup, you can modify the startup script that executes the JAR file. Specifically, you can redirect the output to /dev/null and run the process in the background. Here's how you can adjust the script:

./$SERVICE_NAME".jar" start > /dev/null 2>&1 &

This line does the following:

Additionally, within the Apollo repository, you can control logging behavior through configuration. For instance, setting the LOG_APPENDERS environment variable to "FILE" in the apollo-portal.conf file directs the application to log only to a file, not to the console. This setup is part of how Apollo manages its logging and background execution behavior.

#### Details **Sources** - [apollo-configservice/src/main/scripts/startup.sh](https://github.com/apolloconfig/apollo/blob/master/apollo-configservice/src/main/scripts/startup.sh) - [apollo-portal/src/main/scripts/startup.sh](https://github.com/apolloconfig/apollo/blob/master/apollo-portal/src/main/scripts/startup.sh) - [apollo-assembly/src/main/resources/logback.xml](https://github.com/apolloconfig/apollo/blob/master/apollo-assembly/src/main/resources/logback.xml) - [apollo-portal/src/main/resources/apollo-portal.conf](https://github.com/apolloconfig/apollo/blob/master/apollo-portal/src/main/resources/apollo-portal.conf) - [apollo-adminservice/src/main/scripts/startup.sh](https://github.com/apolloconfig/apollo/blob/master/apollo-adminservice/src/main/scripts/startup.sh) - [apollo-configservice/src/main/resources/apollo-configservice.conf](https://github.com/apolloconfig/apollo/blob/master/apollo-configservice/src/main/resources/apollo-configservice.conf) - [apollo-adminservice/src/main/resources/apollo-adminservice.conf](https://github.com/apolloconfig/apollo/blob/master/apollo-adminservice/src/main/resources/apollo-adminservice.conf) - [apollo-configservice/src/main/resources/logback.xml](https://github.com/apolloconfig/apollo/blob/master/apollo-configservice/src/main/resources/logback.xml)
**About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

nobodyiam commented 6 months ago

you may use vi to edit the ###.jar, and then you will some bash scripts.

Fivemeters commented 6 months ago

you may use vi to edit the ###.jar, and then you will some bash scripts. 好的,我看下,谢谢