I made a small script that can be useful for this function with the pgrep command.
Remember that the script is dependent on cron.
Attention: The script can be useful if you use server only for peerflix-server. Because it checks to see if node.js is running. If you have other processes with node.js can of the problem. But who wants to improve the script, feel free.
Let's put in the folder "/root":
nano checar-peerflix
Paste the code:
#!/bin/bash
#Script criado por: LPServidor
#Website: https://central.lpservidor.org
#--------------------------------------------------------#
#Verificar se o peerflix-server está rodando com o node.js
processo=$(pgrep "node")
if pgrep "node" > /dev/null
then
echo "O node.js está sendo executado neste momento. Bem provalvel que o peerflix-server esteja funcionando!"
echo "Número do processo: $processo"
else
echo "Não foi detectado nenhum processo do node.js ativo, contudo o peerflix-server não está sendo executado. Tentando ligar...\n"
/usr/bin/peerflix-server
fi
save and put in cron to run every 1 minute, use the command crontab -e:
* * * * * sh /root/checar-peerflix
Save again.
Done!
The script will check every 1 minute whether the node.js is running or not. If you will not try to connect peerflix-server.
Sorry for my English, because I did a free translation on google translator, because I speak Brazilian Portuguese.
I made a small script that can be useful for this function with the
pgrep
command.Remember that the script is dependent on
cron
.Attention: The script can be useful if you use server only for peerflix-server. Because it checks to see if
node.js
is running. If you have other processes withnode.js
can of the problem. But who wants to improve the script, feel free.Let's put in the folder "/root":
nano checar-peerflix
Paste the code:
save and put in cron to run every 1 minute, use the command
crontab -e
:* * * * * sh /root/checar-peerflix
Save again.
Done!
The script will check every 1 minute whether the
node.js
is running or not. If you will not try to connect peerflix-server.Sorry for my English, because I did a free translation on google translator, because I speak Brazilian Portuguese.