-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: custom server file location #3401
Feature: custom server file location #3401
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3401 +/- ##
============================================
+ Coverage 51.51% 51.54% +0.03%
- Complexity 2307 2312 +5
============================================
Files 441 441
Lines 13762 13774 +12
Branches 1400 1404 +4
============================================
+ Hits 7089 7100 +11
- Misses 6185 6186 +1
Partials 488 488
Continue to review full report at Codecov.
|
String path = Utils.isOSWindows() ? SERVER_PROPERTIES_WINDOWS : SERVER_PROPERTIES_LINUX; | ||
|
||
File file = new File(path); | ||
File file = ResolvedPaths.SERVER_PROPERTIES.toFile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we make it a little simpler?
e.g.
...
File file = new File(getServerPropertiesPath());
...
String getServerPropertiesPath() {
String serverPropertiesPath = getCustomizedServerPropertiesPath();
if (Strings.isNullOrEmpty(serverPropertiesPath)) {
serverPropertiesPath = Utils.isOSWindows() ? SERVER_PROPERTIES_WINDOWS : SERVER_PROPERTIES_LINUX;
}
return serverPropertiesPath;
}
private String getCustomizedServerPropertiesPath() {
// 1. Get from System Property
String serverPropertiesPath = System.getProperty("apollo.serverPropertiesPath");
if (Strings.isNullOrEmpty(serverPropertiesPath)) {
// 2. Get from OS environment variable
serverPropertiesPath = System.getenv("APOLLO_SERVERPROPERTIESPATH");
}
return serverPropertiesPath;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has Changed to simpler implemention.
How about use APOLLO_PATH_SERVER_PROPERTIES
to instead of APOLLO_SERVERPROPERTIESPATH
for better readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What's the purpose of this PR
Let user can custom file
server.properties
's location through system property or environment variable.Which issue(s) this PR fixes:
#2734
#3389
Brief changelog
Resolve the path of file
server.properties
incom.ctrip.framework.foundation.internals.constant.PathConstants.ResolvedPaths#SERVER_PROPERTIES
,and change
com.ctrip.framework.foundation.internals.provider.DefaultServerProvider
to use it directly.Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean test
to make sure this pull request doesn't break anything.