jakesgordon / javascript-state-machine

A javascript finite state machine library
MIT License
8.69k stars 964 forks source link

how to restore & persist state when i reboot my server? #124

Closed luoboding closed 7 years ago

luoboding commented 7 years ago

i create a StateMachine instance, the instance persist my current state and history, when i reboot my server, the instance is released, how can i restore state?

adami commented 7 years ago

suggestion:

create a 'goto' transition, as explained in docs: {name: 'goto', from: '*', to: function (s) {return s}},

save the current state (in DB, probably) after every transition.

as part of your process init process (after reboot), create the fsm and call fsm.goto()

tsghosh commented 7 years ago

Hi. can you allow file storage to store intermediate state on transition, it can survive a server restart.

luoboding commented 7 years ago

thank you @adami, that sounds good, i'll try your suggestion.