| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package com.leanwo.management;
- import java.io.PrintWriter;
- import java.io.StringWriter;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import javax.swing.SwingUtilities;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
- import org.springframework.context.annotation.ImportResource;
- import com.leanwo.management.util.ProgramStopUtil;
- @SpringBootApplication
- @EnableEurekaServer
- @ImportResource("applicationContext.xml")
- public class ServerManagementApp {
- private static Logger logger = LoggerFactory.getLogger(ServerManagementApp.class);
-
- public static void main(String[] args) {
- System.setProperty("java.awt.headless", "false");
-
- SpringApplication.run(ServerManagementApp.class, args);
-
- JvmExitMonit.jvmExitHook();
-
- ProgramStopUtil.generateStopBat();
- boolean isAutoRun = false;
- if (args != null && args.length > 0) {
- if (args[0].equals("autoRun")) {
- isAutoRun = true;
- }
- for (String arg : args) {
- logger.info("输出参数:" + arg);
- }
- }
- if (isAutoRun) {
- logger.info("程序管理器将会自动运行。");
- }
- final boolean isAutoRunFinal = isAutoRun;
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- try {
- final MainFrame mainFrame = new MainFrame(isAutoRunFinal);
- mainFrame.pack();
- mainFrame.setVisible(true);
-
- // 免配置模式的时候,启动以后界面最小化。
- if(isAutoRunFinal) {
- mainFrame.setExtendedState(JFrame.ICONIFIED);
- }
- } catch (final Exception ex) {
- ex.printStackTrace();
- final StringWriter sr = new StringWriter();
- ex.printStackTrace(new PrintWriter(sr));
- JOptionPane.showMessageDialog(null, sr.toString(), "Error", JOptionPane.ERROR_MESSAGE);
- }
- }
- });
- }
-
- /**
- * 在commons-daemon启动的时候,会调用启动方法
- * @param args
- */
- public static void start(String[] args) {
- main(args);
- }
- /**
- * 在commons-daemon停止的时候,会调用停止的方法
- * @param args
- */
- public static void stop(String[] args) {
- System.exit(0);
- }
- }
|