部署在tocmat的程式執行shell指令碼

2022-01-13 08:05:36 字數 494 閱讀 7946

1 需要把shell指令碼放在resources目錄下。如shell.sh

2需要在tomcat裡面定位到當前shell的目錄,不要定位到了tomcat的目錄裡面去  

定位**

string path1 = thread.currentthread().getcontextclassloader().getresource("").getpath();//獲取當前資源的虛擬路徑

3 完善shell執行命令

string cmd = "bash " +path1 + "shell.sh";

4 執行shell

runtime rt = runtime.getruntime();

process proc = rt.exec(cmd, null, null);

額外小計

通過process proc物件可以獲得後續的輸出流。異常流等  proc.getinputstream();  proc.geterrorstream();

在k8s上部署Springboot

建立service使用者訪問 訪問springboot專案的介面 在教程開始前,大家需要先搭建好k8s集群 harbor私有倉庫和構建自己的springboot映象,可以參考以下文章 使用kubeadm搭建 kubernetes k8s集群 harbor 安裝 dockerfile構建springb...

在apache上部署django 程式

2011 09 21 15 56 38 分類 python django 標籤 apache 字型大小訂閱 1.apache和mod python 1 安裝apache 1 解壓縮 2 進入 apache目錄,執行 sudo configure prefix usr server apache2 e...

在k8s集群上部署服務

建立服務 會建立乙個deployment,若干個pod kubectl run image yyy 其他選項 為服務名 自己起 yyy為映象名 kubectl run my nginx image nginx port 80 或者 kubectl run my nginx image nginx r...