managing Bob node on Linux via script

29 views
Skip to first unread message

Dave

unread,
Mar 29, 2019, 5:06:13 PM3/29/19
to TiddlyWiki
Hi, I'm using Bob every day on linux, and I often come back to the computer after being away and its often disconnected, and a simple browser reload doesn't work.

I have this script running every 30 minutes on a cronjob, but it doesn't always work
if ! pgrep -x "node" > /dev/null
then
    echo "node is Stopped, restarting"
    yad --text="Starting up the Bob..." --timeout=1 --center ;cd /home/david/SyncthingFolders/Bob/TiddlyWiki5;node ./tiddlywiki.js Wikis/BobWiki  --wsserver;
    else 
   echo node is running
   yad --text="node is running fine" --timeout=1 --center 
fi

i.e., sometimes if I do this at the terminal
pgrep -x "node"

it returns a process ID indicating node is running, but I still have to ``pkill node`` to get Bob going.

Is there a better way (by script) to detect if Bob is running properly so I don't have the cronjob kill the script (if I just pkill every 30 minutes) while I'm working in it?


Thanks, 
- Dave



P.S. I just noticed that now that Bob is running there are actually 2 processes of node running now.  Is that a reliable indicator?  If so I'm sure I could detect that in a script


Jed Carty

unread,
Mar 29, 2019, 5:40:10 PM3/29/19
to TiddlyWiki
I have never had that trouble but I suspect that at least part of the problem is that by default if the listed port is in use than the port number is incremented until an open one is found and that port is used.

So Bob may be running on a different port than you expect and when you start Bob again you start up a new instance.

In general I suggest that instead of pgrep to detect if node is running you use a pid file and check for the process id, it will help prevent the problems from starting Bob multiple times on different ports.
The start.sh and stop.sh scripts in the secure server repo demonstrate this (https://gitlab.com/ooktech-public/securewikiserver/tree/master)
Reply all
Reply to author
Forward
0 new messages