watchdog/logs moment

This commit is contained in:
2021-07-11 18:50:21 -05:00
parent 4ccdee79d7
commit 7315ca5c38
4 changed files with 35 additions and 5 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
node_modules node_modules
token token
log

3
readme
View File

@@ -1,7 +1,4 @@
create token file create token file
TODO: TODO:
- in tmux command
- add watchdog
- output all program output to file
- add comments - add comments

View File

@@ -3,6 +3,7 @@
"main": "index.ts", "main": "index.ts",
"scripts": { "scripts": {
"start": "ts-node .", "start": "ts-node .",
"tmux": "tmux new-session -d -s $npm_package_name \"ts-node .\"" "watchdog": "./run.sh",
"tmux": "tmux new-session -d -s $npm_package_name \"./run.sh\""
} }
} }

31
rolemanager/run.sh Normal file
View File

@@ -0,0 +1,31 @@
#/bin/sh
#make log folder
if [[ ! -d log ]]
then
mkdir log
fi
#current file number
num=0
if [[ -f log/number ]]
then
num=$(cat log/number)
fi
echo $num > log/number
#watchdog
while true
do
#increment log file number
num=$(( num + 1 ))
echo $num > log/number
#run
npm start >> log/$num.out 2> log/$num.err
#give chance to close program
sleep 3
echo "\n\n^C to exit\n\n"
done