Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I execute a Windows batch file from forever? #1091

Open
somaholiday opened this issue Jul 5, 2020 · 0 comments
Open

How can I execute a Windows batch file from forever? #1091

somaholiday opened this issue Jul 5, 2020 · 0 comments

Comments

@somaholiday
Copy link

(cross post from StackOverflow)

I'm running Windows 10, and I would like to execute a Windows .bat script from forever (v3.0.0)

forever is installed globally and working fine, and I have successfully used to start other applications.

In this instance I am using a forever JSON config file that looks like:

{
  "uid": "MyApp",
  "command": "cmd.exe",
  "script": ["/c", ".\\scripts\\init-myApp.bat"],
  "sourceDir": "C:\\myApp",
  "logFile": "C:\\myApp\\forever.log",
  "outFile": "C:\\myApp\\out.log",
  "errFile": "C:\\myApp\\error.log",
  "append": true
}

This seems like this should be correct based these facts:

But when I try to run this, I receive a validator error:

internal/validators.js:120
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
    at validateString (internal/validators.js:120:11)
    at Object.join (path.js:375:7)

because forever/cli.js calls path.join on the script option before passing it along to forever-monitor

I have also tried these combinations:

{
  "uid": "MyApp",
  "command": "cmd.exe",
  "script": ".\\scripts\\init-myApp.bat",
  ...
}

which just starts cmd without executing the batch file, and

{
  "uid": "MyApp",
  "command": ["cmd.exe", "/c"],
  "script": ".\\scripts\\init-myApp.bat",
  ...
}

which throws an error in forever-monitor because it assumes command will be a string, not an array.

Is there any way I can pass the necessary /c argument through?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant