-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
47 lines (39 loc) · 1.56 KB
/
Copy pathMain.java
File metadata and controls
47 lines (39 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;
public class Main {
public static void main(String[] args) {
// Print CLI arguments
System.out.println("Java-args-env-file V3\n");
System.out.println("Command Line Arguments:");
for (int i = 0; i < args.length; i++) {
System.out.printf("arg[%d]: %s%n", i, args[i]);
}
// Print environment variables
System.out.println("\nEnvironment Variables:");
for (Map.Entry<String, String> env : System.getenv().entrySet()) {
System.out.printf("%s=%s%n", env.getKey(), env.getValue());
}
// Read and print /config/configs.yaml
readAndPrintFile("/config/configs.yaml", "Config File");
// Read and print /config/secrets
readAndPrintFile("/config/secrets", "Secrets File");
// Sleep for 1 hour
System.out.println("\nSleeping for 1 hour to keep the container alive...");
try {
Thread.sleep(3600_000); // 1 hour = 3600000 ms
} catch (InterruptedException e) {
System.err.println("Sleep interrupted: " + e.getMessage());
}
System.out.println("Done.");
}
private static void readAndPrintFile(String path, String label) {
System.out.printf("%n%s (%s):%n", label, path);
try {
Files.lines(Paths.get(path)).forEach(System.out::println);
} catch (IOException e) {
System.out.printf("Failed to read %s: %s%n", path, e.getMessage());
}
}
}