@@ -128,6 +128,7 @@ public Map<String, String> call() {
128
128
map .put ("vm.compiler1.enabled" , this ::isCompiler1Enabled );
129
129
map .put ("vm.compiler2.enabled" , this ::isCompiler2Enabled );
130
130
map .put ("docker.support" , this ::dockerSupport );
131
+ map .put ("systemd.support" , this ::systemdSupport );
131
132
map .put ("vm.musl" , this ::isMusl );
132
133
map .put ("release.implementor" , this ::implementor );
133
134
map .put ("jdk.containerized" , this ::jdkContainerized );
@@ -484,7 +485,7 @@ protected String dockerSupport() {
484
485
485
486
if (isSupported ) {
486
487
try {
487
- isSupported = checkDockerSupport ();
488
+ isSupported = checkProgramSupport ( " checkDockerSupport()" , Container . ENGINE_COMMAND );
488
489
} catch (Exception e ) {
489
490
isSupported = false ;
490
491
}
@@ -494,6 +495,27 @@ protected String dockerSupport() {
494
495
return "" + isSupported ;
495
496
}
496
497
498
+ /**
499
+ * A simple check for systemd support
500
+ *
501
+ * @return true if systemd is supported in a given environment
502
+ */
503
+ protected String systemdSupport () {
504
+ log ("Entering systemdSupport()" );
505
+
506
+ boolean isSupported = Platform .isLinux ();
507
+ if (isSupported ) {
508
+ try {
509
+ isSupported = checkProgramSupport ("checkSystemdSupport()" , "systemd-run" );
510
+ } catch (Exception e ) {
511
+ isSupported = false ;
512
+ }
513
+ }
514
+
515
+ log ("systemdSupport(): returning isSupported = " + isSupported );
516
+ return "" + isSupported ;
517
+ }
518
+
497
519
// Configures process builder to redirect process stdout and stderr to a file.
498
520
// Returns file names for stdout and stderr.
499
521
private Map <String , String > redirectOutputToLogFile (String msg , ProcessBuilder pb , String fileNameBase ) {
@@ -528,17 +550,17 @@ private void printLogfileContent(Map<String, String> logFileNames) {
528
550
});
529
551
}
530
552
531
- private boolean checkDockerSupport ( ) throws IOException , InterruptedException {
532
- log ("checkDockerSupport() : entering" );
533
- ProcessBuilder pb = new ProcessBuilder ("which" , Container . ENGINE_COMMAND );
553
+ private boolean checkProgramSupport ( String logString , String cmd ) throws IOException , InterruptedException {
554
+ log (logString + " : entering" );
555
+ ProcessBuilder pb = new ProcessBuilder ("which" , cmd );
534
556
Map <String , String > logFileNames =
535
- redirectOutputToLogFile ("checkDockerSupport() : which <container-engine>" ,
536
- pb , "which-container " );
557
+ redirectOutputToLogFile (logString + " : which " + cmd ,
558
+ pb , "which-cmd " );
537
559
Process p = pb .start ();
538
560
p .waitFor (10 , TimeUnit .SECONDS );
539
561
int exitValue = p .exitValue ();
540
562
541
- log (String .format ("checkDockerSupport() : exitValue = %s, pid = %s" , exitValue , p .pid ()));
563
+ log (String .format ("%s : exitValue = %s, pid = %s" , logString , exitValue , p .pid ()));
542
564
if (exitValue != 0 ) {
543
565
printLogfileContent (logFileNames );
544
566
}
0 commit comments