Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Packaged exe is not executing in a specific scenario #1241

Closed
deepakblr opened this issue Jun 29, 2021 · 7 comments
Closed

Packaged exe is not executing in a specific scenario #1241

deepakblr opened this issue Jun 29, 2021 · 7 comments
Labels

Comments

@deepakblr
Copy link

I have built an executable using pkg command ---> lets call it process B.

Scenario:

We have 2 processes

  1. Process A (in C#)
  2. Process B (Generated using pkg command to run js code)

Runtime:
"Process A" starts "Process B".
Process B stops Process A, executes some business logic, and then restarts Process A.

The above 2 steps are repeated every hour.

Problem:

First time when Process A starts Process B, it works as expected.
But next time when the Process A tries to start Process B, it only open the node console. It does not execute the JS file.

Observation:

  1. When I manually run .load "pathtojs/abc.js" on the opened node console, it works fine.
  2. While starting Process B from Process A, if I pass the path of the js file, it works fine, however
    in first iteration, js path is coming as a process argument to my JS process
    but in subsequent iteration, js path is not coming as argument, which essentially means, in subsequent iterations the started
    process is just node console
@jesec
Copy link
Contributor

jesec commented Jul 4, 2021

Sanitize the environment variables before you launch pkg executable from a pkg-launched program.

Specifically PKG_INVOKE_*.

pkg adds it when it launches another program, to allow executing sub programs and avoid infinite loop.

The executed program inherited the variables, will pass it to programs launched by it, and pkg will hit the kill switch.

@deepakblr
Copy link
Author

Thanks Jesec !! I printed and compared the environment variables in the first cycle and the subsequent cycles. I found one additional environment variable in subsequent cycles, I.e. PKG_EXECPATH.
when I reset it to null in subsequent cycles it works absolutely fine.

Now my doubt is whether any additional environment variable I need to check (although I don’t find any additional variable starting from PKG_ except the one I mention d above).
PS: it’s a windows environment

@Hypfer
Copy link
Contributor

Hypfer commented Jul 6, 2021

@deepakblr It would be nice if you could update the readme with this knowledge if it works now :)

@deepakblr
Copy link
Author

@Hypfer for sure !!! Will update it and post here

@deepakblr
Copy link
Author

@Hypfer not able to create Branch, possibly I do not have permission to do so.

@github-actions
Copy link

github-actions bot commented Oct 6, 2021

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

@github-actions github-actions bot added the Stale label Oct 6, 2021
@github-actions
Copy link

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

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

No branches or pull requests

3 participants