|
@@ -1,6 +1,7 @@
|
|
|
package com.its.vds;
|
|
|
|
|
|
import com.its.app.AppUtils;
|
|
|
+import com.its.app.utils.OS;
|
|
|
import com.its.app.utils.SysUtils;
|
|
|
import com.its.vds.config.ProcessConfig;
|
|
|
import com.its.vds.process.DbmsDataProcess;
|
|
@@ -12,11 +13,11 @@ import com.its.vds.xnettcp.center.CenterTcpServerService;
|
|
|
import com.its.vds.xnettcp.vds.VdsTcpClientCommService;
|
|
|
import com.its.vds.xnettcp.vds.process.VdsDataProcess;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.catalina.connector.Connector;
|
|
|
import org.springframework.beans.factory.DisposableBean;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.boot.Banner;
|
|
|
import org.springframework.boot.CommandLineRunner;
|
|
|
+import org.springframework.boot.SpringApplication;
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
|
import org.springframework.boot.context.ApplicationPidFileWriter;
|
|
@@ -45,30 +46,30 @@ import java.net.URL;
|
|
|
public class VdsCommServerApplication implements CommandLineRunner, ApplicationListener<ContextClosedEvent>, InitializingBean, DisposableBean {
|
|
|
//public class VdsCommServerApplication implements ApplicationListener<ContextClosedEvent>, InitializingBean, DisposableBean {
|
|
|
|
|
|
- private Connector connector;
|
|
|
+ private static String applicationName = "vds-comm-server";
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- File file1 = new File("./conf/vds-comm-server.pid");
|
|
|
+ File file1 = new File("./conf/" + applicationName + ".pid");
|
|
|
if (file1.exists()) {
|
|
|
System.out.println(System.getProperty("Program Already Running....."));
|
|
|
log.error("Program Already Running.....");
|
|
|
- //return;
|
|
|
}
|
|
|
|
|
|
- ApplicationContext context = new SpringApplicationBuilder(VdsCommServerApplication.class)
|
|
|
- //.web(WebApplicationType.NONE)
|
|
|
- .listeners(new ApplicationPidFileWriter("./conf/vds-comm-server.pid"))
|
|
|
- .headless(false)
|
|
|
- .bannerMode(Banner.Mode.OFF)
|
|
|
- .run(args);
|
|
|
-
|
|
|
-// SpringApplication application = new SpringApplicationBuilder()
|
|
|
-// .sources(VdsCommServerApplication.class)
|
|
|
-// .listeners(new ApplicationPidFileWriter("./conf/vds-comm-server.pid"))
|
|
|
-// //.headless(false)
|
|
|
-// //.web(WebApplicationType.NONE)
|
|
|
-// .build();
|
|
|
-// application.run(args);
|
|
|
+ if (!OS.isWindows()) {
|
|
|
+ ApplicationContext context = new SpringApplicationBuilder(VdsCommServerApplication.class)
|
|
|
+ //.web(WebApplicationType.NONE)
|
|
|
+ .listeners(new ApplicationPidFileWriter("./conf/" + applicationName + ".pid"))
|
|
|
+ .headless(false)
|
|
|
+ .bannerMode(Banner.Mode.OFF)
|
|
|
+ .run(args);
|
|
|
+ } else {
|
|
|
+ SpringApplication application = new SpringApplicationBuilder()
|
|
|
+ .sources(VdsCommServerApplication.class)
|
|
|
+ .listeners(new ApplicationPidFileWriter("./conf/" + applicationName + ".pid"))
|
|
|
+ .build();
|
|
|
+ application.setBannerMode(Banner.Mode.OFF);
|
|
|
+ application.run(args);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -112,43 +113,45 @@ public class VdsCommServerApplication implements CommandLineRunner, ApplicationL
|
|
|
// schedule enable
|
|
|
processConfig.setStartSchedule(true);
|
|
|
|
|
|
- SwingUtilities.invokeLater(() -> {
|
|
|
- String sysTime = SysUtils.getSysTimeStr();
|
|
|
- //JFrame.setDefaultLookAndFeelDecorated(true);
|
|
|
- JFrame frame = new JFrame("VDS 통신 서버 - [" + sysTime + "]");
|
|
|
- MainUI UI = new MainUI(frame);
|
|
|
- try {
|
|
|
- ClassPathResource file = new ClassPathResource("static/image/application.png");
|
|
|
- URL imgURL = file.getURL();
|
|
|
- frame.setIconImage(new ImageIcon(imgURL).getImage());
|
|
|
- } catch (IOException e) {
|
|
|
- log.error("Not found application icon image");
|
|
|
- }
|
|
|
- frame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
|
|
|
- frame.setContentPane(UI.getRootPanel());
|
|
|
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
- frame.addWindowListener(new WindowAdapter() {
|
|
|
- @Override
|
|
|
- public void windowClosing(WindowEvent e) {
|
|
|
- if (JOptionPane.showConfirmDialog(UI.getRootPanel(), "시스템을 종료 하시겠습니까?", "시스템 종료", 0) == 0) {
|
|
|
- System.exit(0);
|
|
|
- } else {
|
|
|
- frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
|
|
- }
|
|
|
+ if (!OS.isWindows()) {
|
|
|
+ SwingUtilities.invokeLater(() -> {
|
|
|
+ String sysTime = SysUtils.getSysTimeStr();
|
|
|
+ //JFrame.setDefaultLookAndFeelDecorated(true);
|
|
|
+ JFrame frame = new JFrame("VDS 통신 서버 - [" + sysTime + "]");
|
|
|
+ MainUI UI = new MainUI(frame);
|
|
|
+ try {
|
|
|
+ ClassPathResource file = new ClassPathResource("static/image/application.png");
|
|
|
+ URL imgURL = file.getURL();
|
|
|
+ frame.setIconImage(new ImageIcon(imgURL).getImage());
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("Not found application icon image");
|
|
|
}
|
|
|
+ frame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
|
|
|
+ frame.setContentPane(UI.getRootPanel());
|
|
|
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
+ frame.addWindowListener(new WindowAdapter() {
|
|
|
+ @Override
|
|
|
+ public void windowClosing(WindowEvent e) {
|
|
|
+ if (JOptionPane.showConfirmDialog(UI.getRootPanel(), "시스템을 종료 하시겠습니까?", "시스템 종료", 0) == 0) {
|
|
|
+ System.exit(0);
|
|
|
+ } else {
|
|
|
+ frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ frame.pack();
|
|
|
+ frame.setBounds(100, 100, 1000, 600);
|
|
|
+ frame.setLocationRelativeTo(null);
|
|
|
+ frame.setVisible(true);
|
|
|
+
|
|
|
+ JTextArea logArea = UI.getTaLog();
|
|
|
+ logArea.setText(null);
|
|
|
+ JTextAreaOutputStream out = new JTextAreaOutputStream(logArea);
|
|
|
+ System.setOut(new PrintStream(out));
|
|
|
+
|
|
|
+ UI.LoadControllerInfo();
|
|
|
});
|
|
|
- frame.pack();
|
|
|
- frame.setBounds(100, 100, 1000, 600);
|
|
|
- frame.setLocationRelativeTo(null);
|
|
|
- frame.setVisible(true);
|
|
|
-
|
|
|
- JTextArea logArea = UI.getTaLog();
|
|
|
- logArea.setText(null);
|
|
|
- JTextAreaOutputStream out = new JTextAreaOutputStream(logArea);
|
|
|
- System.setOut(new PrintStream(out));
|
|
|
-
|
|
|
- UI.LoadControllerInfo();
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void terminateApplication() {
|