0

I have a nodejs compiled application that I run from a terminal window on my ubuntu vps.Is there a way to run it in the background, meaning i can afford to close my terminal window and it still works. Note this exe prints the messages on the terminal window when its running

tried PM2, it errors out saying "awaiting restart" tried nohup, it does not error out and shows process has started but exe does not what it shall do, meaning its not working. if i do ./app , it works but then i can not close the terminal window.

blackninja
  • 11
  • 1
  • 5
  • 1
    I'm not sure if there is a direct way with the nodejs command but you could consider running your node app in a Docker container – tim545 May 29 '19 at 06:52
  • 1
    Possible duplicate of [How do I run a node.js app as a background service?](https://stackoverflow.com/questions/4018154/how-do-i-run-a-node-js-app-as-a-background-service) – JackRed May 29 '19 at 07:29
  • [Docker](https://nodejs.org/en/docs/guides/nodejs-docker-webapp/) is a really good option You can also use [forever](https://www.npmjs.com/package/forever) – JackRed May 29 '19 at 07:32
  • You should use `pm2` check why it throws an error. you can find it on the keymetrics dashboard – Thamaraiselvam May 29 '19 at 07:48
  • error i get when i run it via PM2 `2|bot | internal/modules/cjs/loader.js:468 2|bot | if (request.charAt(0) !== '.' || 2|bot | ^ 2|bot | 2|bot | TypeError: Cannot read property 'charAt' of undefined` – blackninja May 29 '19 at 10:11
  • with forever i get `Forever processing file: ./bot` but it never runs. No errors – blackninja May 29 '19 at 10:13
  • Thanks @JackRed , I will check Docker now. – blackninja May 29 '19 at 10:14

1 Answers1

0

used tmux, loving it so far. think might use PM2 with tmux where i can.

blackninja
  • 11
  • 1
  • 5