@@ -499,12 +499,13 @@ secured accordingly. Use `chmod` so that the file can only be read by the owner
499
499
500
500
[[deployment-systemd-service]]
501
501
==== Installation as a systemd service
502
- Systemd is the successor to ` init.d` scripts , and now being used by many many modern Linux
503
- distributions. Although you can continue to use `init.d` script with `systemd`, it is also
504
- possible to launch Spring Boot applications using `systemd` '`service`' scripts.
502
+ Systemd is the successor of the System V init system , and is now being used by many modern
503
+ Linux distributions. Although you can continue to use `init.d` scripts with `systemd`, it
504
+ is also possible to launch Spring Boot applications using `systemd` '`service`' scripts.
505
505
506
- For example, to run a Spring Boot application installed in `var/myapp` as user `myapp` you
507
- can add the following script in `/etc/systemd/system/myapp.service`:
506
+ Assuming that you have a Spring Boot application installed in `/var/myapp`, to install a
507
+ Spring Boot application as a `systemd` service create a script named `myapp.service` using
508
+ the following example and place it in `/etc/systemd/system` directory:
508
509
509
510
[indent=0]
510
511
----
@@ -521,7 +522,23 @@ can add the following script in `/etc/systemd/system/myapp.service`:
521
522
WantedBy=multi-user.target
522
523
----
523
524
524
- TIP: Remember to change the `Description` and `ExecStart` fields for your application.
525
+ TIP: Remember to change the `Description`, `User` and `ExecStart` fields for your
526
+ application.
527
+
528
+ Note that unlike when running as an `init.d` service, user that runs the application, PID
529
+ file and console log file behave differently under `systemd` and must be configured using
530
+ appropriate fields in '`service`' script. Consult the
531
+ http://www.freedesktop.org/software/systemd/man/systemd.service.html[service unit
532
+ configuration man page] for more details.
533
+
534
+ To flag the application to start automatically on system boot use the following command:
535
+
536
+ [indent=0,subs="verbatim,quotes,attributes"]
537
+ ----
538
+ $ systemctl enable myapp.service
539
+ ----
540
+
541
+ Refer to `man systemctl` for more details.
525
542
526
543
527
544
0 commit comments