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

Unifies the polykey.ts and polykey-agent.ts to make forking to background portable to bundling #39

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

CMCDragonkai
Copy link
Member

Description

This unifies the polykey.ts and polykey-agent.ts so that way forking to the background is portable.

Issues Fixed

Tasks

  • 1. Switching between normal polykey and agent mode with --agent-mode internal flag.
  • 2. The globalThis.PK_MAIN_EXECUTABLE is a special property set to always the file path of the main executable. This should also work for pkg, but needs to be tested on the CI with Ubuntu, right now set to __filename, but it can be changed to import.meta.url in ESM.

Final checklist

  • Domain specific tests
  • Full tests
  • Updated inline-comment documentation
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

@CMCDragonkai
Copy link
Member Author

One of the things I observed is that error reporting from agent start --background isn't good atm, it does not tell you why it failed. Like that there was an error or something. We need to improve the error reporting.

@ghost
Copy link

ghost commented Oct 19, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@CMCDragonkai
Copy link
Member Author

This works for the esbuilt bundle:

[nix-shell:~/Projects/Polykey-CLI]$ ./dist/polykey.js agent start --background
✔ Please enter the password … ******
pid	269435
nodeId	"vj4tcqd7fom79fo3q418g1616739260ngdibpteguvaid49kcakjg"
clientHost	"::1"
clientPort	46311
agentHost	"::"
agentPort	42836

Need to test on the CI for pkg and ubuntu.

@CMCDragonkai CMCDragonkai self-assigned this Oct 19, 2023
@CMCDragonkai CMCDragonkai merged commit d171fb6 into staging Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Starting agent in background doesn't work with esbuilt bundle
1 participant