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: blockchain logs show in cockpit #1367

Merged
merged 1 commit into from
Mar 5, 2019

Conversation

andremedeiros
Copy link
Collaborator

@andremedeiros andremedeiros commented Feb 25, 2019

There are two ways to launch the blockchain process with Embark: standalone, by running embark blockchain, or with the dashboard, by running embark run.

When Embark runs, it also starts an IPC server that is used, amongst other things, to receive logs from potentially the standalone process. The problem is that the log listener for the standalone blockchain process starts independently of the blockchain process launcher, which will try to start a blockchain process even if one is already running. Each of these also registers an API endpoint which is supposed to serve logs. As the API endpoint is the same for both, one overwrites the other, and in this case BlockchainListener always won.

This PR sets things up in a way that BlockchainListener will only register its API endpoint if, and only if, an IPC connection occurs. The standalone blockchain process has a retry loop that will attempt to connect to IPC every so often, so once it connects, it will now send the logs that IPC missed plus any future logs.

You suck, @emizzle

Copy link
Collaborator

@emizzle emizzle left a comment

Choose a reason for hiding this comment

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

Hate to do this to you man, but when you get a chance tomorrow, could you please add a bit of a description for what the problem was and how it was fixed? Just because it was pretty confusing to work out what the issue was, it may help us down the line when we forget again 😃

@@ -118,6 +118,10 @@ class IPC {
cb = cb || (() => {});
return cb();
}
this.queueRequest(action, data, cb);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't really need this anymore do we? 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. Fixing.

@andremedeiros andremedeiros force-pushed the fix/blockchain-logs-in-cockpit branch from 866865f to 75665c1 Compare February 26, 2019 17:16
@andremedeiros
Copy link
Collaborator Author

could you please add a bit of a description for what the problem was

I was pretty burnt out after waking up at 3 am last night. Sorry for not adding a description in the first place. Fixed!

@@ -135,10 +139,13 @@ Blockchain.prototype.initStandaloneProcess = function () {
// `embark run` without restarting `embark blockchain`)
setInterval(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than use setInterval, my preference would be for a recursive setTimeout. Reason: although unlikely, because the interval is 2000ms, there is a possibility of overlapped calls of this.ipc.connect, i.e. if for some reason the previous invocation's callback hasn't fired yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That makes sense, agreed.

@andremedeiros andremedeiros merged commit 41256cf into master Mar 5, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix/blockchain-logs-in-cockpit branch March 5, 2019 19:14
emizzle added a commit that referenced this pull request Mar 11, 2019
#1367 introduced a change that prevented the `blockchain_listener` from listening to logs until the IPC server connected. However, the restriction went too far, and included restricting registration of console commands and API endpoints for the regular transactions feature.

This fix reverts the changes that affect registration of regular txs endpoints and console commands.
iurimatias pushed a commit that referenced this pull request Mar 11, 2019
#1367 introduced a change that prevented the `blockchain_listener` from listening to logs until the IPC server connected. However, the restriction went too far, and included restricting registration of console commands and API endpoints for the regular transactions feature.

This fix reverts the changes that affect registration of regular txs endpoints and console commands.
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.

4 participants