#!/bin/bash

echo ""
echo "===="
echo "Stopping the NodeJs-based Next server is currently a manual process"
echo "Select the appropriate PID from the following, and run kill <pid>"
echo "----"

ps auxww | grep "next start" | grep node


echo "----"
echo ""


pids=$(ps auxww | grep "next" | awk '{print $2}')
num_pids=$(echo $pids | wc -w)


if [ $num_pids == 0 ] ; then
    echo "**** No running NodeJS-based Next servers found!"
else
    echo "Suggested kill commands:"
    echo ""

    for pid in $pids ; do
	echo "  kill $pid"
    done
fi

echo "----"
echo ""
