Unitech / Unitech/pm2

pm2 does not work with bat file on Windows

Open
#5,235 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

starting pm2 with a .bat file raised an error

What do you expect?

I expect pm2 to work with Windows scripts (.bat, .cmd, .ps files) and documentation updated accordingly, or a more clear documentation about restrictions (if any) on Windows.
All samples, or code snippets in the documentation is about .sh scripts (so with Linux).

Environment

  • Windows 10
  • NodeJS: v14.17.1
  • NPM: v6.14.13
  • pm2: v5.1.2

How could we reproduce this issue?

test-pm2.bat:

@timeout /t 30

then try: pm2 start test-pm2.bat

Supporting information

pm2 error log file:

@timeout /t 30
^

SyntaxError: Invalid or unexpected token
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Object.<anonymous> (C:\Tools\node\node-v14.17.1-win-x64\node_modules\pm2\lib\ProcessContainerFork.js:33:23)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue on Windows with the provided test-pm2.bat and pm2 start test-pm2.bat. Start at lib/ProcessContainerFork.js, named in the stack trace, and trace how script files are launched. Done means Windows batch scripts work as requested, or the relevant documentation clearly describes supported scripts and restrictions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.