Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
9dfbc25e
Commit
9dfbc25e
authored
Oct 06, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
e130c00e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
19 deletions
+41
-19
RedisMetricRepository.java
...tuate/metrics/repository/redis/RedisMetricRepository.java
+2
-2
ApplicationPidListener.java
...framework/boot/actuate/system/ApplicationPidListener.java
+29
-8
ApplicationPidListenerTests.java
...work/boot/actuate/system/ApplicationPidListenerTests.java
+3
-1
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+7
-8
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMetricRepository.java
View file @
9dfbc25e
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/system/ApplicationPidListener.java
View file @
9dfbc25e
...
@@ -26,13 +26,12 @@ import org.springframework.boot.context.event.ApplicationStartedEvent;
...
@@ -26,13 +26,12 @@ import org.springframework.boot.context.event.ApplicationStartedEvent;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.core.Ordered
;
import
org.springframework.core.Ordered
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.SystemPropertyUtils
;
/**
/**
* An {@link org.springframework.context.ApplicationListener} that saves application PID
* An {@link org.springframework.context.ApplicationListener} that saves application PID
* into file. This application listener will be triggered exactly once per JVM, and the
file
* into file. This application listener will be triggered exactly once per JVM, and the
*
name can be overridden at runtime with a System property or environment variable named
*
file name can be overridden at runtime with a System property or environment variable
* "PIDFILE" (or "pidfile").
*
named
"PIDFILE" (or "pidfile").
*
*
* @author Jakub Kubrynski
* @author Jakub Kubrynski
* @author Dave Syer
* @author Dave Syer
...
@@ -46,6 +45,8 @@ public class ApplicationPidListener implements
...
@@ -46,6 +45,8 @@ public class ApplicationPidListener implements
private
static
final
String
DEFAULT_FILE_NAME
=
"application.pid"
;
private
static
final
String
DEFAULT_FILE_NAME
=
"application.pid"
;
private
static
final
String
[]
PROPERTY_VARIABLES
=
{
"PIDFILE"
,
"pidfile"
};
private
static
final
AtomicBoolean
created
=
new
AtomicBoolean
(
false
);
private
static
final
AtomicBoolean
created
=
new
AtomicBoolean
(
false
);
private
int
order
=
Ordered
.
HIGHEST_PRECEDENCE
+
13
;
private
int
order
=
Ordered
.
HIGHEST_PRECEDENCE
+
13
;
...
@@ -74,10 +75,30 @@ public class ApplicationPidListener implements
...
@@ -74,10 +75,30 @@ public class ApplicationPidListener implements
*/
*/
public
ApplicationPidListener
(
File
file
)
{
public
ApplicationPidListener
(
File
file
)
{
Assert
.
notNull
(
file
,
"File must not be null"
);
Assert
.
notNull
(
file
,
"File must not be null"
);
String
actual
=
SystemPropertyUtils
.
resolvePlaceholders
(
"${PIDFILE}"
,
true
);
String
override
=
getOverride
();
actual
=
!
actual
.
contains
(
"$"
)
?
actual
:
SystemPropertyUtils
.
resolvePlaceholders
(
"${pidfile}"
,
true
);
if
(
override
!=
null
)
{
actual
=
!
actual
.
contains
(
"$"
)
?
actual
:
file
.
getAbsolutePath
();
this
.
file
=
new
File
(
override
);
this
.
file
=
new
File
(
actual
);
}
else
{
this
.
file
=
file
;
}
}
private
String
getOverride
()
{
for
(
String
property
:
PROPERTY_VARIABLES
)
{
try
{
String
override
=
System
.
getProperty
(
property
);
override
=
(
override
!=
null
?
override
:
System
.
getenv
(
property
));
if
(
override
!=
null
)
{
return
override
;
}
}
catch
(
Throwable
ex
)
{
System
.
err
.
println
(
"Could not resolve '"
+
property
+
"' as system property: "
+
ex
);
}
}
return
null
;
}
}
@Override
@Override
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/system/ApplicationPidListenerTests.java
View file @
9dfbc25e
...
@@ -67,7 +67,9 @@ public class ApplicationPidListenerTests {
...
@@ -67,7 +67,9 @@ public class ApplicationPidListenerTests {
System
.
setProperty
(
"PIDFILE"
,
this
.
temporaryFolder
.
newFile
().
getAbsolutePath
());
System
.
setProperty
(
"PIDFILE"
,
this
.
temporaryFolder
.
newFile
().
getAbsolutePath
());
ApplicationPidListener
listener
=
new
ApplicationPidListener
(
file
);
ApplicationPidListener
listener
=
new
ApplicationPidListener
(
file
);
listener
.
onApplicationEvent
(
EVENT
);
listener
.
onApplicationEvent
(
EVENT
);
assertThat
(
FileCopyUtils
.
copyToString
(
new
FileReader
(
System
.
getProperty
(
"PIDFILE"
))),
not
(
isEmptyString
()));
assertThat
(
FileCopyUtils
.
copyToString
(
new
FileReader
(
System
.
getProperty
(
"PIDFILE"
))),
not
(
isEmptyString
()));
}
}
}
}
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
9dfbc25e
...
@@ -465,11 +465,11 @@ HTTPS connector:
...
@@ -465,11 +465,11 @@ HTTPS connector:
[[howto-use-tomcat-behind-a-proxy-server]]
[[howto-use-tomcat-behind-a-proxy-server]]
=== Use Tomcat behind a front-end proxy server
=== Use Tomcat behind a front-end proxy server
Spring Boot will automatically configure Tomcat's `RemoteIpValve` if you enable it. This
allows you to
Spring Boot will automatically configure Tomcat's `RemoteIpValve` if you enable it. This
transparently use the standard `x-forwarded-for` and `x-forwarded-proto` headers that
allows you to transparently use the standard `x-forwarded-for` and `x-forwarded-proto`
most front-end proxy servers add. The valve is switched on by setting one or both of these
headers that most front-end proxy servers add. The valve is switched on by setting one or
properties to something non-empty (these are the conventional values used by most proxies, and if
both of these properties to something non-empty (these are the conventional values used by
you only set one the other will be set automatically):
most proxies, and if
you only set one the other will be set automatically):
[indent=0]
[indent=0]
----
----
...
@@ -477,9 +477,8 @@ you only set one the other will be set automatically):
...
@@ -477,9 +477,8 @@ you only set one the other will be set automatically):
server.tomcat.protocol_header=x-forwarded-protocol
server.tomcat.protocol_header=x-forwarded-protocol
----
----
If your proxy uses different headers you can
If your proxy uses different headers you can customize the valve's configuration by adding
customize the valve's configuration by adding some entries to `application.properties`,
some entries to `application.properties`, e.g.
e.g.
[indent=0]
[indent=0]
----
----
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment