java fat包掉linux脚本
server1open.sh
#!/bin/bash nohup /usr/local/jdk/jdk1.8.0_151/bin/java -classpath /usr/local/xwhgames/server/server-1.0-SNAPSHOT-jar-with-dependencies.jar com.server.xwh.run.RunGameShit common_47.xxx.xxx.171_1 ./program >/dev/null 2>/dev/null & echo success
server1shut.sh
#!/bin/bash #tcp deal eval pid17788=$(netstat -tlunp | awk '{if($4 == "0.0.0.0:17788") print $7} ' | cut -d "/" -f 1) kill -9 $pid17788 #tcp6 deal eval pid1778817788=$(netstat -tlunp | awk '{if($4 == ":::17788") print $7} ' | cut -d "/" -f 1) kill -9 $pid1778817788 echo success
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <head> <title>游戏启动</title> <script type="text/javascript" th:src="@{./static/js/jquery-3.3.1.min.js}"></script> </head> <body> <div> <div onclick="order('r0')" style="width:200px;height:200px;float: left;background-image: url('static/images/orange.jpg')"></div> <div onclick="order('d0')" style="width:200px;height:200px;float: left;background-image: url('static/images/red.jpg')"></div> <div onclick="order('s_1_0')" style="width:200px;height:200px;float: left;background-image: url('static/images/yellow.jpg')"></div> </div> <p/> <div> <div onclick="order('r1')" style="width:200px;height:200px;float: left;background-image: url('static/images/head_icon_1.jpg')"></div> <div onclick="order('d1')" style="width:200px;height:200px;float: left;background-image: url('static/images/head_icon_2.jpg')"></div> <div onclick="order('s_1_1')" style="width:200px;height:200px;float: left;background-image: url('static/images/head_icon_3.jpg')"></div> </div> </body> <script type="text/javascript" th:inline="javascript"> /*<![CDATA[*/ function order(id){ $.ajax({ type: "GET", url: 'http://' + window.location.host + '/order?id='+id, dataType: "text", success: function (data) { alert(data); } }); } /*]]>*/ </script> </html>
package com.xwhb.http.verticles; import io.vertx.core.AbstractVerticle; import io.vertx.ext.web.Router; import io.vertx.ext.web.handler.StaticHandler; import io.vertx.ext.web.templ.ThymeleafTemplateEngine; import java.io.BufferedReader; import java.io.InputStreamReader; public class GameShellVerticle extends AbstractVerticle { @Override public void start() throws Exception { super.start(); final ThymeleafTemplateEngine engine = ThymeleafTemplateEngine.create(); final Router router = Router.router(vertx); router.route("/static/*").handler(StaticHandler.create("webStatic/static")); router.get("/").handler(ctx -> { engine.render(ctx, "webStatic/", "gamer.html", res -> { if (res.succeeded()) { ctx.response().end(res.result()); } else { ctx.fail(res.cause()); } }); }); router.get("/order").handler(ctx -> { String id = ctx.request().getParam("id"); vertx.executeBlocking(f -> { try { String shpath=""; if(id.equals("r0")){ shpath="/usr/local/xwhgames/shell/routopen.sh"; }else if(id.equals("r1")){ shpath="/usr/local/xwhgames/shell/routshut.sh"; }else if(id.equals("d0")){ shpath="/usr/local/xwhgames/shell/dbopen.sh"; }else if(id.equals("d1")){ shpath="/usr/local/xwhgames/shell/dbshut.sh"; }else if(id.equals("s_1_0")){ shpath="/usr/local/xwhgames/shell/server1open.sh"; }else if(id.equals("s_1_1")){ shpath="/usr/local/xwhgames/shell/server1shut.sh"; } Process ps = Runtime.getRuntime().exec(shpath); ps.waitFor(); BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream())); StringBuffer sb = new StringBuffer(); String line; while ((line = br.readLine()) != null) { sb.append(line).append("\n"); } String result = sb.toString(); System.out.println(result); ctx.response().putHeader("content-type", "text/html; charset=utf-8"); ctx.response().end(result); } catch (Exception e) { e.printStackTrace(); } },false,res -> {}); System.out.println("here"); }); vertx.createHttpServer().requestHandler(router::accept).listen(9788); System.out.println("GameShellVerticle 启动完成"); } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】