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

Move redis launch to node #118

Merged
merged 13 commits into from May 1, 2020
Merged

Move redis launch to node #118

merged 13 commits into from May 1, 2020

Conversation

ChrisP19
Copy link
Contributor

No description provided.

fyu
fyu previously approved these changes Apr 28, 2020
app/src/js/server/main.ts Outdated Show resolved Hide resolved
@fyu fyu self-requested a review April 28, 2020 01:24
@fyu fyu dismissed their stale review April 28, 2020 01:24

wrong click

@fyu fyu marked this pull request as draft April 28, 2020 01:24
@fyu fyu changed the title [WiP] Move redis launch to node Move redis launch to node Apr 28, 2020
@ChrisP19 ChrisP19 marked this pull request as ready for review April 28, 2020 04:21
app/src/js/server/util.ts Outdated Show resolved Hide resolved
throw new Error(`Cannot find ${config.data}`)
}

if (!(await fs.pathExists(config.itemDir))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

itemDir is optional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check happens after the config is supplemented by the default config, so itemDir will always have a value here. Don't we need to verify that the dir exists? Otherwise there may be an error when saving later.

Copy link
Contributor

@fyu fyu Apr 30, 2020

Choose a reason for hiding this comment

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

It may not exist if the user doesn't specify it. It is not necessary unless the user wants to server local data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So we should only check the itemDir if the database is local? In the case where database is local but itemDir is not specified, should we throw an error that the default itemDir is missing?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can set the default itemDir to empty string. We only check whether the itemDir exists when local FSU’s used and itemDir is not empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

})

// wait 1 s before trying to connect to the server
await sleep(1000)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any other signal we can wait for?

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 can't find any signal Redis emits when it starts up. One alternative would be to wait a smaller time (like 100 ms) in a loop, try to connect, and catch the failure. So it tries to connect every 100 ms. We could also have some maximum cutoff time (like 2-3 s).

Copy link
Contributor

Choose a reason for hiding this comment

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

Long polling sounds better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so this means leave it at 1 second?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant taking the alternative approach you mentioned. Wait for a small amount of time, and check the status. Raise failure after a timeout.

Copy link
Contributor Author

@ChrisP19 ChrisP19 May 1, 2020

Choose a reason for hiding this comment

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

It turns out Redis has polling built in.
So I just removed the sleep, and disabled the "connection failed" error logging by default

@fyu fyu merged commit a53e7be into master May 1, 2020
@fyu fyu deleted the redis_to_node branch May 1, 2020 23:33
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.

None yet

2 participants