Is this correct, it looks like the Init event is shown in the example, so i am wondering if the example code is incorrect?
Trying to determine the easiest way in Go to determine if current node is the Primary. I have a cron failing when it tries to run on the non-primary.
Can LiteFS set a ENV variable and maintain that on a machine on the current primary? I don’t know if ENV changes outside a app’s thread, can pick up changes. But that seems cleaner than files on disk, for the app to access.
Good catch. I just pushed up a fix. The init and primaryChange events have the same payload at the moment. The type field was incorrect in the example.
There’s a GET /info endpoint that you can check the isPrimary status from. We made a few updates to it recently. We haven’t publicly documented it but it seems like it would be useful.
AFAIK, another process can’t update environment variables for another running process. We have talked about adding a /litefs/.isprimary file to show true or false as to whether the local node is currently primary or not. It’s still file-based but it might be more straightforward than the .primary file?