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

Allow restarting Peacock while the game is active #34

Merged
merged 1 commit into from
Jan 19, 2023

Conversation

LennardF1989
Copy link
Member

Currently if you restart Peacock, you will lose the in-memory UserProfile that got created during the /oauth/token-call, causing pretty much everything to topple over and requiring the user to go offline-mode first. On top of that, you will also lose any active contractSession, because they are only ever persisted if you make a save.

This PR fixes the first issue by checking if the unique_name in the JWT token is already loaded into memory on every request. It does this using a cheap check, so it's only a very minor overhead on each request.

The contractSession issue is not really fixed with this PR, but silently averted by creating a newSession on the fly. It's not a pretty solution, but it works.

All in all, this PR allows developers to make changes to Peacock and restart the server without being forced to go to offline-mode, saving valuable development time. For normal end-users, it's not really useful in a local server situation.

That said, while outside the scope of this PR, we should probably consider using a different mechanism to store volatile data, eg. by storing them in a fast NoSQL-like database (Eg. AceBase: https://github.com/appy-one/acebase)

@LennardF1989 LennardF1989 enabled auto-merge (rebase) November 19, 2022 22:27
@LennardF1989
Copy link
Member Author

Due to the developer-oriented nature of this PR, we could also just add a developer-flag for the .use() in index.ts, and inside the !session-check in the eventHandler. Then again, it does have valid uses for normal users in that they can reload Peacock while messing with their plugins.

@Small-cart

This comment was marked as duplicate.

@RDIL RDIL changed the base branch from v5 to v6 January 19, 2023 20:39
@LennardF1989 LennardF1989 merged commit 2cc63c9 into thepeacockproject:v6 Jan 19, 2023
@LennardF1989 LennardF1989 deleted the restart branch January 19, 2023 21:09
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.

2 participants