mirror of
https://github.com/TheWhiteDog9487/WebAPI.git
synced 2026-08-11 23:01:30 +08:00
Closes #3
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.thewhitedog9487"
|
group = "xyz.thewhitedog9487"
|
||||||
version = "0.5.1"
|
version = "0.5.2"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class OpenAPIConfiguration {
|
|||||||
.contact(new Contact()
|
.contact(new Contact()
|
||||||
.name("TheWhiteDog9487")
|
.name("TheWhiteDog9487")
|
||||||
.url("https://www.github.com/TheWhiteDog9487/WebAPI"))
|
.url("https://www.github.com/TheWhiteDog9487/WebAPI"))
|
||||||
.version("0.5.1")
|
.version("0.5.2")
|
||||||
.license(new License()
|
.license(new License()
|
||||||
.name("WTFPL")
|
.name("WTFPL")
|
||||||
.url("https://spdx.org/licenses/WTFPL")) )
|
.url("https://spdx.org/licenses/WTFPL")) )
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
import org.springframework.boot.system.ApplicationHome;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -35,10 +36,13 @@ class SystemdInstallerManager implements CommandLineRunner {
|
|||||||
""";
|
""";
|
||||||
|
|
||||||
@Autowired ObjectProvider<GatewayDiscordClient> DiscordClientProvider;
|
@Autowired ObjectProvider<GatewayDiscordClient> DiscordClientProvider;
|
||||||
|
ApplicationHome AppHome = new ApplicationHome( SystemdInstallerManager.class );
|
||||||
String CurrentOS = System.getProperty("os.name");
|
String CurrentOS = System.getProperty("os.name");
|
||||||
String CurrentUser = System.getProperty("user.name");
|
String CurrentUser = System.getProperty("user.name");
|
||||||
Path CurrentExecutableFilePath = GetExecutblePath();
|
Path CurrentExecutableFilePath = GetExecutblePath();
|
||||||
Path WorkingDirectory = CurrentExecutableFilePath.getParent();
|
Path WorkingDirectory = AppHome
|
||||||
|
.getDir()
|
||||||
|
.toPath();
|
||||||
Path ServiceFileDirectory = Path.of("/etc/systemd/system/");
|
Path ServiceFileDirectory = Path.of("/etc/systemd/system/");
|
||||||
Path ServiceFileName = Path.of("WebAPI.service");
|
Path ServiceFileName = Path.of("WebAPI.service");
|
||||||
String SoftLinkFileName = "Current";
|
String SoftLinkFileName = "Current";
|
||||||
@@ -73,20 +77,18 @@ class SystemdInstallerManager implements CommandLineRunner {
|
|||||||
log.debug("ExecutablePath: {}", ExecutablePath);
|
log.debug("ExecutablePath: {}", ExecutablePath);
|
||||||
return Path.of((String) ExecutablePath); }
|
return Path.of((String) ExecutablePath); }
|
||||||
else{
|
else{
|
||||||
log.debug("IsImageCode is false");
|
|
||||||
// ↓ 没有错误,但是获取Jar包位置的代码在catch里面,扔一个异常出去以进入catch分支
|
// ↓ 没有错误,但是获取Jar包位置的代码在catch里面,扔一个异常出去以进入catch分支
|
||||||
// ↓ 这个主要是针对使用GraalVM的JVM而不是Native Image的情况
|
// ↓ 这个主要是针对使用GraalVM的JVM而不是Native Image的情况
|
||||||
throw new RuntimeException("Not Image Code"); }
|
throw new RuntimeException("Not Image Code"); }
|
||||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException |
|
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException |
|
||||||
RuntimeException e) {
|
RuntimeException e) {
|
||||||
try {
|
try {
|
||||||
return Path.of(SystemdInstallerManager.class
|
return AppHome
|
||||||
.getProtectionDomain()
|
.getSource()
|
||||||
.getCodeSource()
|
.toPath()
|
||||||
.getLocation()
|
.toRealPath();
|
||||||
.toURI());
|
} catch (IOException ex) {
|
||||||
} catch (URISyntaxException ex) {
|
throw new RuntimeException(ex); } } }
|
||||||
throw new RuntimeException(ex);}}}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) throws Exception {
|
public void run(String... args) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user