gitlab CICD nodejs app when server goes down

I have a nodejs code that i want to write a CICD pipeline in Gitlab. I installed gitlab-runner executor “shell” on my server and my .gitlab-ci.yml is as below:

variables:
    GIT_CLEAN_FLAGS: none
stages: 
  - build
  - deploy  
cache: 
  paths: 
    - node_modules/
build: 
  script: 
    - "ls -la"
    - "npm install" 
  
  stage: build
  tags: 
    - backend


deploy: 
  tags: 
    - backend
  stage: deploy
  environment: 
    name: deploy
  script: 
    - "pm2 restart backend"

I run my code once at the beginning manually on my target server and then I restart the process with pm2. The reason I use pm2 instead of “node server.js” is that when is run my code with “node” the job never terminated as someone said in this link :GitLab CI stuck on running NodeJS server so I use pm2 to run my process in background and job terminate.
It works fine but when my server goes down then comes up after , I have an error that this process doesnot exist. Is there any better approach that i can use instead of this to prevent this problem?