Restarting of ghost blog instance failed - Howto bypass the error

Restarting of ghost blog instance failed - Howto bypass the error

By restarting my ghost blog with ghost restart -d /working/dir/ command failed with:

user@server:~$ ghost restart -d /dir/dirofblog/

Love open source? We’re hiring Node.js Engineers to work on Ghost full-time.
https://careers.ghost.org/product-engineer-node-js

Running in development mode

✖ Restarting Ghost
A CliError occurred.

Message: An unexpected error occurred while stopping Ghost.

Debug Information:
    OS: OS
    Node Version: v16.x
    Ghost Version: 5.x
    Ghost-CLI Version: 1.21.0
    Environment: development
    Command: 'ghost restart -d /dir/dirofblog/'

Additional log info available in: /home/user/.ghost/logs/ghost-cli-debug-2022-xxx.log

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/ghost-cli/ for troubleshooting.

So it seems I've got some problems by updating etc in development mode and ghost doctor also doesen't work here.

Nodejs permissions are the Problem:

I can suid the nodejs bin with your root user: chmod u+s /usr/bin/node or you can just run: killall -9 node

Easy and best way with the bash helper Script:

You have just to edit the line:  GDIR="/user/dir/to/ghost"

#!/bin/bash

# GHOST HELPER 0.1 (c) suuhmer
# To bypass node policy problems to kill
#

# Setup you dir here:
GDIR="/user/dir/to/ghost"

clear
echo
echo "°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"
echo "° GHOST HELPER 0.1 (c) suuhmer °"
echo "°                              °"
echo "°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"
echo

if [ "$1" == "--update" ]; then
   ghost status
   echo
   echo "Update ready.. now sleep and restart.."
   echo && sleep 2
   killall node 2>/dev/null ; ghost update -d $GDIR
   sleep 2; ghost restart -d $GDIR
   echo "DONE; exit"; echo
   ghost status
   exit 0
elif [ "$1" == "--restart" ]; then
   echo "Restart only.. now sleep and restart.."
   ghost status
   echo && sleep 2
   killall node 2>/dev/null ; ghost restart -d $GDIR
   echo "DONE; exit" ; echo
   ghost status
   exit 0
elif [ "$1" == "--status" ]; then
   echo "Get Status"
   echo
   ghost status
   echo && sleep 2
   exit 0
else
   echo "Something went wrong.. exit now.."
   echo
   echo "Usage: $0 --status | --restart | --update "
   exit 1;
fi