Commit Graph

328 Commits

Author SHA1 Message Date
Spring Buildmaster
2a83e80a9b Next Development Version 2017-03-03 14:39:21 +00:00
Spring Buildmaster
5c12500366 Next Development Version 2017-01-30 20:10:13 +00:00
Spring Buildmaster
a2696bf873 Next Development Version 2017-01-30 11:40:24 +00:00
Spring Buildmaster
ed1ce140c0 Next Development Version 2017-01-26 14:20:39 +00:00
Phillip Webb
3d619da553 Polish 2017-01-25 16:56:22 -08:00
Andy Wilkinson
cd5124005b Deprecate support for module layout
Closes gh-8008
2017-01-25 16:40:42 +00:00
Stephane Nicoll
505e7f75ea Polish contribution
Closes gh-8089
2017-01-25 11:01:53 +01:00
dreis
d58f38f6f6 Use String.replace() with single char if possible
See gh-8089
2017-01-25 11:01:52 +01:00
Andy Wilkinson
080ff49c8d Prevent AspectJ from loading aspects too early
Previously, AspectJ would find META-INF/aop.xml almost as soon as
the jar was launched, and before LaunchedURLClassLoader had been
created. This meant that AspectJ would attempt to load aspects listed
in META-INF/aop.xml but that were package in BOOT-INF/classes and,
therefore, could not be loaded.

This commit updates the Repackager so that a META-INF/aop.xml file
is moved into BOOT-INF/classes. This ensures that it isn't visible
to the app class loader so it won't be loaded to early. It will
now be loaded by LaunchedURLClassLoader which can also load the
compiled aspects that aop.xml references.

Closes gh-7587
2017-01-20 16:51:51 +00:00
Alessandro Falappa
ec537b307e Make start/stop run-levels configurable in INIT-INFO of launch.script
See gh-7008
Closes gh-7902
2017-01-18 14:24:29 +00:00
Andy Wilkinson
803eddf6b2 Update test to reflect quoting of STOP_WAIT_TIME in launch.script 2017-01-04 21:39:16 +00:00
Andy Wilkinson
c5e7d83e2d Fix shellcheck warnings for literal { and } characters in launch.script
Closes gh-7870
2017-01-04 21:30:42 +00:00
Andy Wilkinson
75cb545361 Update launch.script to use a consistent location for pid file
Closes gh-6924
2017-01-04 20:39:51 +00:00
Johnny Lim
f915ae197a Polish 2017-01-04 09:53:45 +01:00
Phillip Webb
41b83085a6 Restore kill -9 to launch.script force-stop
Restore the `-9` flag to the send `kill` call which was inadvertently
lost in commit a35a1022c2.

Closes gh-6223
2017-01-02 19:47:54 -08:00
Phillip Webb
a35a1022c2 Update force-stop to respect STOP_WAIT_TIME
Closes gh-6223
2016-12-30 13:23:47 -08:00
Kazuki Shimizu
40691d07f8 Add force-stop to launch.script usage
See gh-6223
Closes gh-7787
2016-12-30 13:19:36 -08:00
Phillip Webb
aacf5d660f Update copyright year for changed files 2016-12-30 11:53:51 -08:00
Gaurav Rawat
509be7474d Add force-stop support to launch script
Update the embedded launch script to support `force-stop`.

Closes gh-6223
2016-12-29 22:20:05 -08:00
Spring Buildmaster
9057f9ae1f Next development version 2016-12-23 00:15:23 +00:00
Johnny Lim
e12b4a944f Polish 2016-12-21 20:18:04 -08:00
Lucas Saldanha
534a9db6fd Make stop wait time in the launch script configurable
Create a parameter `STOP_WAIT_TIME` for the startup script
that configures the time in seconds to wait for a normal
shutdown. Because of #4941 we also send a shutdown half
way the countdown.

Fixes gh-7121
2016-12-20 15:15:12 -08:00
Phillip Webb
6121208cbb Polish formatting 2016-12-19 12:47:03 -08:00
Phillip Webb
4b9cba351b Merge branch '1.4.x' into 1.5.x 2016-12-19 12:36:57 -08:00
Phillip Webb
bd74c3d327 Polish formatting 2016-12-19 12:25:09 -08:00
Alessandro Falappa
dd7d81a580 INIT INFO Required Start/Stop as embedded launch script properties
Expose the Required-Start and Require-Stop lines in the launch script
INIT INFO section as customizable embedded launch script properties.

This way one can express dependencies fron other init services by simply
changing the configuration in the build script.

Closes gh-7555
2016-12-15 14:14:50 +01:00
Johnny Lim
6d1b752ffe Polish
Closes gh-7552
2016-12-14 19:14:24 +01:00
Andy Wilkinson
0df03a95f0 Merge branch '1.4.x' into 1.5.x 2016-12-02 11:33:52 +00:00
Pei-Tang Huang
5a5e2db134 Quote $jarfile when creating arguments in launch script
Previously, if the pathname of fully executable contained any space
characters, the launch script would fail to locate the jar file

This commit fixes this issue by quoting the jarfile.

Closes gh-7535
2016-12-02 11:31:51 +00:00
Johnny Lim
423f8037ce Polish
Closes gh-7530
2016-11-30 08:31:13 +01:00
Andy Wilkinson
1595286e04 Prefer @SpringBootApplication-annotated class when finding main class
Closes gh-6496
2016-11-29 15:44:10 +00:00
Dave Syer
c6c6524b40 Support custom fat jar layouts
Allow support for custom Lyout implementations with both the Maven
and Gradle plugin. Implementations of `LayoutFactory` can now be
specified to allow customization of the layout. In addition a
layout may now implement `CustomLoaderLayout` if it wishes to
write custom loader classes.

See gh-7263
2016-11-28 16:31:53 -08:00
Phillip Webb
f5b03c81f3 Rework Repacakger timeout code
Pull up common timeout code into Repackager and remove the need for
custom subclasses.

See gh-7263
2016-11-28 16:15:39 -08:00
Christian Koops
5c11059e1d Make launch script's logFilename and pidFilename configurable via properties
Closes gh-7234
2016-11-22 13:54:16 +00:00
Johnny Lim
8038882d46 Polish
Closes gh-7403
2016-11-16 13:36:51 -08:00
Spring Buildmaster
e712a9ba8c Next Development Version 2016-11-08 16:55:37 +00:00
Phillip Webb
97fee46682 Revert Layout changes
This reverts commits:
- 974ec92ad6.
- 537e0c12c2.
- 500a3df6e9.
2016-10-31 21:08:15 -07:00
Stephane Nicoll
974ec92ad6 Fix broken build 2016-10-31 10:37:57 +01:00
Dave Syer
537e0c12c2 Support for custom layout types to change loader classes
A layout can
also optionally change the loader jar that is unpacked in the root
of the repackaged archive by implementing a new method in Layout.
2016-10-30 11:24:29 +00:00
Dave Syer
500a3df6e9 Add LayoutFactory in spring.factories
Instead of a fixed enum of layout types, user can provide custom
layouts via implementations of LayoutFactory in spring.factories.
2016-10-30 11:24:29 +00:00
Stephane Nicoll
ae4dd0d17e Merge branch '1.4.x' into 1.5.x 2016-10-24 18:08:23 +02:00
Stephane Nicoll
a638dcd51b Remove unnecessary use of System.out.println 2016-10-24 18:07:40 +02:00
Andy Wilkinson
899b8a04cb Merge branch '1.4.x' into 1.5.x 2016-10-14 09:20:02 +01:00
Andy Wilkinson
24f8c737fb Make relative PID_FOLDER and LOG_FOLDER absolute using jar's directory
Closes gh-7092
Closes gh-7093
2016-10-14 09:19:11 +01:00
Andy Wilkinson
57b7357be7 Merge branch '1.4.x' into 1.5.x 2016-10-13 16:55:21 +01:00
Andy Wilkinson
03deff9a1c Handle relative pid folder correctly in the launch script
Previously, a relative PID folder was not handled correctly when
running stop, status, or force_reload. This meant that a service
could be started when configured to use a relative pid file, but
then could not be stopped.

The PID folder should be treated as relative to the service's jar
file. This commit updates stop, status, and force_reload to push the
jar file's directory so that this is now the case for those three
commands.

Closes gh-7092
2016-10-13 16:51:54 +01:00
Phillip Webb
d818a09ed8 Polish 2016-10-11 23:38:14 -07:00
Stephane Nicoll
28ed59ca6e Polish contribution
Closes gh-6645
2016-10-11 15:36:35 +02:00
Plamen Totev
3cccc732df Add workingDirectory option for Maven plugin run/start
Add configuration option that specifies the working directory to use to
run/start the application via the Maven plugin.

Closes gh-6243
2016-10-11 15:36:27 +02:00
Andy Wilkinson
8971c8ba54 Merge branch '1.4.x' into 1.5.x 2016-09-23 13:56:53 +01:00
Andy Wilkinson
e1d53b65ba Remove redundant git-commit-id-plugin configuration from loader-tools
Closes gh-7007
2016-09-23 13:56:38 +01:00
Stephane Nicoll
6bd670edbc Initiate 1.4.x branch 2016-09-21 11:11:24 +02:00
Spring Buildmaster
7e9ed5e1a7 Next Development Version 2016-09-21 07:58:07 +00:00
Spring Buildmaster
5f959b074f Next Development Version 2016-09-20 20:20:06 +00:00
Andy Wilkinson
5afd610855 Merge branch '1.3.x 2016-09-19 09:28:23 +01:00
Andy Wilkinson
93ab01263c Change the ownership of the pid folder when using a sub-folder
This is an alternative to the fix made in 3b52909 which removed the
chown call entirely.

Prior to 3b52909, the ownership of $PID_FOLDER was always changed even
when its value was /var/run. This was problematic as it could prevent
other services from creating their pid folder or file.

When a sub-folder is used, changing its ownership so that it’s owned by
the user that will run the app is desirable as it limits access to the
folder. Rather than removing the chown call entirely, this commit
ensures that it only happens when a sub-folder is being used to hold the
pid file.

Closes gh-6532
2016-09-19 09:27:38 +01:00
Phillip Webb
825dd0a26c Merge branch '1.3.x' 2016-09-16 15:07:18 -07:00
Phillip Webb
3b52909fc2 Don't change ownership of PID_FOLDER
Update the launch script so that it no longer changes ownership of the
PID_FOLDER.

Commit b24e736cfe had changed the chown
line from:
	chown "$run_user" "$PID_FOLDER/${identity}"
to:
	chown "$run_user" "$PID_FOLDER"

This meant that it was possible for the launch script to change
ownership of `/var/run` and prevent later processes from writing to
the folder.

Since PID_FOLDER is created before the chown statement, and that
the `checkPermissions` function runs to ensure that the PID file can
be written, it appears that the chown is not even required.

Fixes gh-6532
2016-09-16 14:35:21 -07:00
Andy Wilkinson
742657983b Improve the error message when additional build-info prop has null value
Closes gh-6724
2016-08-23 11:30:23 +01:00
Andy Wilkinson
b47da0d265 Fix spellcheck warning introduced in 6bbd50e0
Closes gh-6628
2016-08-11 20:35:47 +01:00
Andy Wilkinson
8c106af384 Allow default value for CONF_FOLDER to be set at build time
Closes gh-6549
2016-08-11 20:25:59 +01:00
Andy Wilkinson
899b851c6f Remove META-INF/INDEX.LIST when repackaging a jar file
META-INF/INDEX.LIST files are pointless in an executable jar and
moving application classes from the root of the jar to
BOOT-INF/classes breaks the index, resulting in an
InvalidJarIndexException being thrown.

This commit updates the Repackager to automatically remove a
META-INF/INDEX.LIST file from a jar file that is being repackaged.

Closes gh-6601
2016-08-10 13:23:49 +01:00
Spring Buildmaster
334baaeffd Next development version 2016-07-28 19:54:01 +00:00
Spring Buildmaster
a89ef5df6e Next Development Version 2016-07-28 09:18:40 +00:00
Spring Buildmaster
2216369348 Next Development Version 2016-07-04 14:15:02 +00:00
Dave Syer
9e8beb7323 Merge remote-tracking branch 'origin/1.3.x' 2016-06-14 09:56:18 +01:00
Dave Syer
e4b544bd39 Create PID_FOLDER if it doesn't exist
In fact the folder was already created if the app is running as
a different user, but not if running as the current user, so it
was just a question of moving one line out of an if block.

Fixes gh-5986
2016-06-14 09:54:58 +01:00
Andy Wilkinson
183613a5ca Merge branch '1.3.x' 2016-05-13 11:41:58 +01:00
Andy Wilkinson
4c65e5e704 Always handle quoted arguments correctly in the launch script
Previously, arguments passed to the script were handled in one way
if a service was being started using start-stop-daemon and in another
way if start-stop-daemon wasn’t available or the application is being
launched in run mode. This meant that quoted arguments were only 
handled correctly when the application was being started using
start-stop-daemon.

This commit updates the launch script so that argument handling is
the same across all three different way that the application can be
launched.

Closes gh-5942
2016-05-13 11:13:54 +01:00
Christian Flamm
6bbd50e084 Update launch script to canonicalize jarfolder
Previously, if the folder which contained the jar was a symlink the
launch script would use the symlinked folder's name when determining
the default identity.

This commit updates the launch script so that symlinks are resolved
and the canonical name of the folder which contains the jar is used
when determining the script's default identity. The behaviour when
APP_NAME has been set is unchanged.

Closes gh-5679
Closes gh-5733
2016-05-10 16:20:33 +01:00
Spring Buildmaster
819a9574a6 Next Development Version 2016-05-10 05:28:34 +00:00
Spring Buildmaster
376bbe68d8 Next Development Version 2016-05-06 11:23:57 +00:00
Stephane Nicoll
21536f64e1 Polish info contributor feature
This commit improves the `InfoContributor` infrastructure as follows:

* `InfoEndpoint` no longer breaks its public API and returns a Map as
before
* `Info` is now immutable
* All properties of the build are now displayed. Since we control the
generation of that file, there is no longer a mode to restrict what's
shown
* Build info is now generated in `META-INF/build-info.properties` by
default

Closes gh-5734
2016-05-06 10:52:26 +02:00
Phillip Webb
5bc274ca09 Polish 2016-04-12 13:23:43 -07:00
Andy Wilkinson
1d4e52cc2b Merge branch '1.3.x' 2016-04-06 11:47:42 +01:00
Christian Brunotte
677080b8e2 Update launch.script so popd does not print directory name to stdout
Closes gh-5394
2016-04-06 11:46:36 +01:00
Andy Wilkinson
58ca9a1c5d Add a BuildInfo task for generating build.properties with Gradle
The commit adds a new BuildInfo task that can be used to generate
a build.properties file, intended for inclusion in the Actuator's
info endpoint.

A default instance of the task can be configure using the plugin's
DSL:

springBoot {
	buildInfo()
}

Additional properties can also be configured using the DSL:

springBoot {
	buildInfo {
		additionalProperties = [
			'foo': 'bar'
		]
	}
}

When configured via the DSL, the Java plugin's classes task is
configured to depend on the build info task. Alternatively, if more
control is required, the task can be declared and configured manually:

task buildInfo(type: org.springframework.boot.gradle.buildinfo.BuildInfo) {
	additionalProperties = [
		'foo': 'bar'
	]
}

classes {
	dependsOn buildInfo
}

See gh-2559
2016-03-24 08:59:55 +00:00
Phillip Webb
73cbb2f40a Polish 2016-03-03 09:14:24 -08:00
Stephane Nicoll
7f3ee2e405 Disable attach of repackaged artifact
This commit allows to generate the packaged artifact only locally by
adding a new `attach` property. If `attach` is set to `false` explicitly,
only the main artifact is installed/deployed.

Closes gh-5258
2016-03-01 11:12:59 +01:00
Andy Wilkinson
ad7cf48497 Update Repackager to use Java 8 APIs safely
Previously, Repackager used Java 8 APIs without protecting against the
possibility of a NoSuchMethodError on earlier versions of Java.
This commit wraps the Java 8 APIs in try-catch blocks to ensure
that they do not cause a failure on Java versions before 8, while
still making full use of Java 8's capabilities when available.

Closes gh-5280
2016-02-29 15:11:28 +00:00
Andy Wilkinson
779649bfdb Merge branch '1.3.x' 2016-02-29 14:53:52 +00:00
Andy Wilkinson
bb473c32e2 Enable Animal Sniffer checking of spring-boot-loader-tools
Previously, Animal Sniffer checking of spring-boot-loader-tools
was disabled as it failed with an NPE. This has been fixed in
Animal Sniffer 1.15.

This commit upgrades Animal Sniffer to 1.15 and adds the necessary
annotations to suppress failures for safe usage of sun.* and Java 7
APIs.

Note that UsesUnsafeJava has been copied from spring-boot and made
package-private. This retains the clearer intent of the custom
annotation (versus @IgnoreJRERequirement) while avoiding the change
in the build order that would be necessary for
spring-boot-loader-tools to use the annotation from spring-boot.

Closes gh-5284
2016-02-29 14:44:27 +00:00
Uwe Schaefer
9c3003071b Add CONF_FOLDER property
Closes gh-5203
2016-02-29 11:36:59 +01:00
Spring Buildmaster
225d877ab9 Next Development Version 2016-02-26 01:06:16 -08:00
Andy Wilkinson
af32d6e8ee Allow LOG_FOLDER and PID_FOLDER defaults to be set at build time
This commit enhances the default launch script to allow the default
values for LOG_FOLDER and PID_FOLDER to be set at build time. They
can now be set using the logFolder and pidFolder properties
respectively.

Closes gh-4787
2016-02-25 12:25:41 +00:00
Andy Wilkinson
44ddfcc7fa Upgrade copyright headers of all files changed in 2016 2016-02-25 12:09:42 +00:00
Phillip Webb
4b55144d80 Polish 2016-02-19 16:19:22 -08:00
Andy Wilkinson
5ed4ef1272 Add manifest entries for location of lib and classes in executable archives
Closes gh-5183
2016-02-19 17:04:51 +00:00
Andy Wilkinson
87fe0b2ade Use a conventional delegation model in LaunchedURLClassLoader
When an application is run as an executable archive with nested jars,
the application's own classes need to be able to load classes from
within the nested jars. This means that the application's classes need
to be loaded by the same class loader as is used for the nested jars.
When an application is launched with java -jar the contents of the
jar are on the class path of the app class loader, which is the
parent of the LaunchedURLClassLoader that is used to load classes
from within the nested jars. If the root of the jar includes the
application's classes, they would be loaded by the app class loader
and, therefore, would not be able to load classes from within the
nested jars.

Previously, this problem was resolved by LaunchedURLClassLoader being
created with a copy of all of the app class laoder's URLs and by
using an unconventional delegation model that caused it to skip its
parent (the app class loader) and jump straight to its root class
loader. This ensured that the LaunchedURLClassLoader would load both
the application's own classes and those from within any nested jars.
Unfortunately, this unusual delegation model has proved to be
problematic. We have seen and worked around some problems with Java
Agents (see gh-4911 and gh-863), but there are others (see gh-4868)
that cannot be made to work with the current delegation model.

This commit reworks LaunchedURLClassLoader to use a conventional
delegate model with the app class loader as its parent. With this
change in place, the application's own classes need to be hidden
from the app class loader via some other means. This is now achieved
by packaging application classes in BOOT-INF/classes (and, for
symmetry, nested jars are now packaged in BOOT-INF/lib). Both the
JarLauncher and the PropertiesLauncher (which supports the executable
jar layout) have been updated to look for classes and nested jars in
these new locations.

Closes gh-4897
Fixes gh-4868
2016-02-19 14:15:40 +00:00
Phillip Webb
00cfe1d054 Use AssertJ in spring-boot-tools
See gh-5083
2016-02-06 15:51:26 -08:00
Phillip Webb
fbaf209240 Move master to 1.4.0.BUILD-SNAPSHOT 2016-01-24 10:45:24 -08:00
Spring Buildmaster
504d3e97ba Next development version 2016-01-21 18:41:30 -08:00
Andy Wilkinson
854cacdb4f Fix useStartStopDaemon in launch script and allow config via conf file
Commit 5a1ee6eb added support for disabling use of start-stop-daemon
via a placeholder in the default launch script. Unfortunately, that
placeholder was subsequently broken in 81a47639.

This commit reinstates the placeholder and adds tests to verify that all
of the placeholders in the launch script can be replaced and that they
have the required default values. Furthermore, it also allows the use of
start-stop-daemon to be configured via USE_START_STOP_DAEMON in an
app’s .conf file. This allows the configuration to be changed after the
app has been built.

Closes gh-4985
2016-01-21 14:58:51 +00:00
Andy Wilkinson
487a66a75f Resend SIGTERM if app is still running 30 seconds after first attempt
Previously, the default launch script would send SIGTERM once and then
wait for up to 60 seconds for the app to have stopped. If the service
was stopped immediately after being started the first SIGTERM would
occasionally be ignored (presumably because the JVM was not yet in a
state to handle it) causing the service stop request to fail.

This commit updates the launch script to resend SIGTERM to the process
if it's still running 30 seconds after the first SIGTERM was sent.

Closes gh-4941
2016-01-14 10:37:45 +00:00
Andy Wilkinson
3afd0c7b3b Address Shellcheck warning (SC2086) for $arguments in launch script
$arguments needs to be split on spaces so it can’t just be wrapped
in quotes. This commit updates arguments to be an array that is then
expanded ("{arguments[@]}"). The use of @ and double quotes means that
it is expanded into all elements individually quoted.

See gh-4866
2016-01-14 10:37:37 +00:00
Andy Wilkinson
c39a55a270 Fix quoting of start-stop-daemon RUN_ARGS and JAVA_OPTS in launch script
81a4763 introduced a regression when multiple RUN_ARGS or JAVA_OPTS were
configured. Rather than the JVM being launched with multiple arguments
all of the RUN_ARGS or JAVA_OPTS were passed as a single argument. This
caused unexpected behaviour and typically caused the application to fail
to start.

This commit updates the quoting of the arguments the are supplied when
launching the app using start-stop-daemon so that space-separated
entries in RUN_ARGS and JAVA_OPTS remain separate.

Closes gh-4866
2016-01-13 13:28:14 +00:00
Andy Wilkinson
04fe55a2ab Improve portability by using type instead of which in the launch script
Previously, the launch script used which to determine the availability
of start-stop-daemon. which isn’t available by default on all OSs.
For example, it’s not available by default on CentOS 5.

This commit updates the launch script to use type when determining if
start-stop-daemon is available. This improves the portability of the
script and makes the use of type consistent throughout the script.

Closes gh-4925
2016-01-13 13:28:14 +00:00
Andy Wilkinson
a1e0f2f5f0 Update launch script to wait for pid to be written to pid file
Previously, the launch script would wait for the pid file to exist
before continuing. This didn’t work 100% of the time as it left a 
window where the file had been created but the PID had not been written
to it that could result in an incorrect report of the app failing to
start.

This commit updates the script to wait for the file to have a size
greater than zero before continuing. This ensures that the pid has
been written to the file before the pid is read from the file and used
to check that the process is running.

Closes gh-4923
2016-01-13 13:28:14 +00:00
Johannes Edmeier
832ad2fe85 Change redirect in initscript to support old bash
`&>>` syntax is bash version 4. This fix allows to support older
versions.

Fixes gh-4820
Closes gh-4829
2015-12-24 11:44:55 +01:00
Spring Buildmaster
8db59059a5 Next Development Version 2015-12-18 05:43:02 -08:00