From 297276c5d67481ffee469d4e62bce1a1b64dee64 Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Fri, 9 Oct 2020 23:04:16 +0800 Subject: [PATCH] init --- .gitignore | 1 + Dockerfile | 11 +++++++++++ shell/findPortPid | 8 ++++++++ shell/killNode | 17 +++++++++++++++++ shell/savePid | 17 +++++++++++++++++ shell/updateRisk | 25 +++++++++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 shell/findPortPid create mode 100644 shell/killNode create mode 100644 shell/savePid create mode 100644 shell/updateRisk diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fd45131 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:current-alpine3.12 + + +RUN mkdir /app +COPY shell/* /app +WORKDIR /app +RUN git clone git@gogs.kirito.cool:panqihua/RiskCloudRun.git +WORKDIR /app/RiskCloudRun + +CMD ["node","/bin/www"] + diff --git a/shell/findPortPid b/shell/findPortPid new file mode 100644 index 0000000..aed0c1d --- /dev/null +++ b/shell/findPortPid @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ $# == 1 ] +then + netstat -antp|grep $1|awk '{c=$7;split(c,d,"/");print match(d[1],/\d+/)?d[1]:-1}' +else + echo port param not found! +fi diff --git a/shell/killNode b/shell/killNode new file mode 100644 index 0000000..3a87deb --- /dev/null +++ b/shell/killNode @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ -e *.log ] +then + pid=`stat *.log|awk 'NR>1{next}{c=$0;gsub(/\D/,"",c);print c}'` + kill -9 $pid + if [ $? -eq 0 ] + then + echo "kill $pid success" + rm -f *.log + ./run.sh + else + echo "kill $pid error" + fi +else + ./run.sh +fi diff --git a/shell/savePid b/shell/savePid new file mode 100644 index 0000000..8a0ab23 --- /dev/null +++ b/shell/savePid @@ -0,0 +1,17 @@ +#!/bin/sh + +echo "findPort $1" +while true + do + pid=`findPortPid $1` + if [ -z $pid ] + then + echo "pid not found!!!" + sleep 1s + else + echo "pid is $pid" + touch $pid.log && chmod +x $pid.log + break + fi + done + diff --git a/shell/updateRisk b/shell/updateRisk new file mode 100644 index 0000000..41406a8 --- /dev/null +++ b/shell/updateRisk @@ -0,0 +1,25 @@ +#!/bin/sh + + +cd /app +export webclient='RiskCloudMock' +export webServer='RiskCloudFontend' + +export PORT=2233 +export webClient=https://risk.kirito.cool +export serverPort=5000 +export listenAddress=0.0.0.0 +export apiServer=https://risk.kirito.cool + + +function run(){ + if [ ! -e $1 ] + then + git clone git@gogs.kirito.cool:panqihua/$1.git + fi + cd $1 && git reset --hard && git pull && yarn && chmod +x run.sh && killNode +} + +run $webclient +run $webServer +