Skip to content

Instantly share code, notes, and snippets.

@NeilMasters
Created November 1, 2023 14:07
Show Gist options
  • Save NeilMasters/f91effe4d561e02c9c22db3ede1d4c79 to your computer and use it in GitHub Desktop.
Save NeilMasters/f91effe4d561e02c9c22db3ede1d4c79 to your computer and use it in GitHub Desktop.
monitor node service and restart if required
#!/bin/bash
# This small script will check the running processes for the
# node service running the application. If it is not found it
# will start another instance of the service.
SOCKET_SERVICES_RUNNING=$(ps -aux | grep "[n]ode index.js")
if [ "${SOCKET_SERVICES_RUNNING}" == ""]; then
cd /srv/app && (npm run serve&)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment