typescript-sdk
typescript-sdk copied to clipboard
Start Keploy server from Typescript-SDK
Fixes #352 If the keploy mode is record and test then it will check if keploy is running on port 6789 and if it isn't then it will start an asynchronously process to start the keploy server and the server won't keeping running, it will stop the server as soon as the main app server stops
Hi @Frey0-0, we should start the Keploy server from Keploy class constructor in src/keploy.ts because middleware is called on API call only. But we should check for Keploy binary during user API server setup.
Yes that makes sense @re-Tick cause it may be possible the binary is not even present. I will look into this and mention if I have any issues here only. Thanks for the review 😄
@re-Tick I have made the changes now we check if the keploy
binary is present or not and next if it is running on port 6789
and if it is present and not running then it will spawn a process to start the server
Hi @Frey0-0, I have tried these changes in my local but the keploy binary do not run from the spawn method call.
the spawn method call will run the binary as long as the node server is running and it will be terminated if the node server is stopped because the parent process has stopped. Please have a look at this video below.
This is on my system which has the keploy binary installed Screen Recording
This is a system which doesn't have the keploy binary
The keploy server stops if we stop the node server and can be started from the command again Screen Recording
I have found an interesting issue due to which Keploy binary is trying to run on the same port
as the sample API server. This is because Keploy runs on port defined by PORT
env variable or 6789 (default).
So, we can solve this by changing the env variable name in keploy to "KPORT"
You can repklicate this by:
Oh yes! I faced the same error and we should change the name of the Keploy Port. Should I add an issue and then raise a PR for this or directly raise a PR for this describing the issue for the variable name change?
I have created an issue and also linked a PR for it. @re-Tick Please review it :) and are there any more changes that need to be done on this PR?
LGTM. Please add the link in GSOC task list