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

fix 'cannot take exclusive lock for project' error #332

Merged
merged 1 commit into from
May 9, 2024
Merged

Conversation

adnanhashmi09
Copy link
Contributor

The CLI had an issue where it would throw error cannot take exclusive lock for project "dora-metrics": process with PID 113930 is still running. This was caused by another instance of docker-watch running or not exiting properly. So the solution was to parse the log and look for this error. Then from that extract the PID of the process and run the kill command. Now when we run the kill command we toggle the retry useState flag so that the useEffect starts again thereby starting docker-watch again.

Now the other problem was that the error was getting caught due to process.on('close'.......) which in turn resulted in the execution of the handleExit() function. To avoid this, a circular buffer was created to store the last 10 logs, and when the 'close' event is triggered we search for the specific error and if found, we simply resolve the promise.

const items: T[] = [];
let index = this.head;
for (let i = 0; i < this.size; i++) {
items.push(this.buffer[index]!);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
items.push(this.buffer[index]!);
items.push(this.buffer[ (index+this.head) % this.size]!);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might help in getting logs in order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted it in order of creation. Wouldn't above suggestion return it in order the buffer is laid out in memory?

@adnanhashmi09 adnanhashmi09 merged commit 12cbc5a into main May 9, 2024
1 check passed
@adnanhashmi09 adnanhashmi09 deleted the cli-fixes branch May 9, 2024 15:46
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

Successfully merging this pull request may close these issues.

3 participants