Allow restarting Peacock while the game is active #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)