Jelajahi Sumber

删除服务器文件

wuweihao 3 tahun lalu
induk
melakukan
3269ad9f2d

+ 2 - 2
gis_application/pom.xml

@@ -13,7 +13,7 @@
     <groupId>com.gis</groupId>
     <artifactId>gis_application</artifactId>
     <version>1.0.0</version>
-    <packaging>war</packaging>
+    <packaging>jar</packaging>
     <name>gis_application</name>
     <description>项目入口</description>
 
@@ -37,7 +37,7 @@
                 <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
         </plugins>
-        <finalName>cmsBigScene</finalName>
+        <finalName>big_scene</finalName>
     </build>
 
 

+ 1 - 1
gis_application/src/main/resources/application-sit.properties

@@ -47,7 +47,7 @@ spring.redis.jedis.pool.max-wait=-1ms
 
 
 #log
-logging.path=/root/user/cms_bin_scene_log
+logging.path=/root/log/big_scene_log
 logging.config=classpath:logback-spring.xml
 logging.level.com.gis=debug
 

+ 4 - 0
gis_service/src/main/java/com/gis/service/impl/SceneServiceImpl.java

@@ -196,6 +196,10 @@ public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implem
             e.printStackTrace();
         }
         log.info("文件上传到oss完成: {}", ossPath);
+
+        // 2022-5-16 删除物理文件-直接删除edit目录
+        FileUtil.del(basePath);
+
         return Result.success((Object) ossPath);
     }
 

+ 10 - 0
gis_web/src/main/java/com/gis/web/controller/SceneController.java

@@ -142,10 +142,16 @@ public class SceneController extends BaseController {
     @GetMapping("removes/{ids}")
     public Result removes(@PathVariable String ids) {
         List<SceneEntity> entities = sceneService.findByIds(ids);
+        String filePath;
         for (SceneEntity entity: entities) {
+            filePath = entity.getPath();
             entity.setRecStatus("I");
             entity.setUpdateTime(new Date());
             sceneService.update(entity);
+
+            // 2022-5-16 物理删除-删除服务器文件
+            FileUtil.del(filePath);
+            log.info("删除文件地址:{}", filePath);
         }
 
         return Result.success();
@@ -193,6 +199,10 @@ public class SceneController extends BaseController {
 
                 QiniuOssUtil.upload(filePath, OSS_PATH + path);
                 log.info("oss文件上传完成 ");
+
+                // 2022-5-16 物理删除-删除服务器文件
+                FileUtil.del(filePath);
+                log.info("删除文件地址:{}", filePath);
             } catch (IOException e) {
                 e.printStackTrace();
             }

+ 60 - 0
run.sh

@@ -0,0 +1,60 @@
+#!/bin/sh
+APP_NAME=big_scene.jar
+APP_PORT=8105
+APP_EVN=$2   #执行环境 sit|pro
+APP_ORDER=$1   #执行方法  start|stop|restart
+# 获取进程号
+APP_PID=`netstat -ntpl | grep $APP_PORT | grep LISTEN | awk '{print $7}' | awk -F "/" '{print $1}'`
+
+
+# 启动命令
+startApp(){
+    if [ ${APP_PID} ];
+    then
+    	echo "程序已经在运行了"
+    else
+    	echo "执行 start 方法"
+    	nohup java -jar -Xmx3072M -Xms512M ./$APP_NAME --spring.profiles.active=$APP_EVN --server.port=$APP_PORT > logs.log 2>error.log &  # 说明pid为空
+	echo Start Success!
+fi
+}
+
+# 停止命令
+stopApp(){
+    echo "执行 stop 方法"
+    if [ ${APP_PID} ];
+	then
+		echo $APP_NAME "存在,执行 stop 方法"
+			kill -9 ${APP_PID} && echo 'Kill Process!'
+	else
+		echo $APP_NAME 没有运行
+    fi
+}
+
+# 重启命令
+restartApp(){
+    echo " 1 执行 restart 方法"
+	stopApp
+	APP_PID=''  #将进程号置空
+	sleep 2
+	echo "进程号:" ${APP_PID} 
+	echo " 2 执行 restart 方法"
+	startApp
+}
+
+# 判断执行命令 取第一个参数
+case $APP_ORDER in
+    "start")
+        startApp
+        ;;
+    "stop")
+        stopApp
+        ;;
+	"restart")
+		restartApp
+        ;;
+        *)
+     ;;
+esac
+
+