-
Notifications
You must be signed in to change notification settings - Fork 297
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
syncservice: implementation and migration #775
Conversation
Still looking through this. Annotated High level flow through the syncservice after this PR is. sequenceDiagram
santactl ->> santasyncservice: syncWithLogListener
Note over santactl,santasyncservice: Service is spun up by launchd if needed
alt is clean sync
santasyncservice ->> santad: "setSyncCleanRequired:YES"
else
end
santasyncservice ->> syncserver: preflight
santasyncservice --> santactl: "didReceiveLog (messages for preflight)"
syncserver -->> santasyncservice: preflight response
santasyncservice --> santactl: "didReceiveLog (messages for preflight response)"
santasyncservice ->> syncserver: eventUpload
syncserver -->> santasyncservice: eventUploadResponse (200)
santasyncservice ->> syncserver: ruleDownload
santasyncservice --> santactl: "didReceiveLog (messages for ruleDownload )"
syncserver --> santasyncservice: ruleDownload response (200)
santasyncservice ->> santad: databaseRuleAddRules
santasyncservice ->> santad: setRuleSyncLastSuccess
santasyncservice ->> santad: postRuleSyncNotificationWithCustomMessage
santasyncservice --> santactl: "didReceiveLog (messages for ruleDownload response)"
santasyncservice ->> syncserver: postFlight request
santasyncservice -->> santactl: "didReceiveLog (messages for postFlight)"
syncserver -->> santasyncservice: postFlight response
santasyncservice -->> santactl: "didReceiveLog (messages for postFlight response)"
santasyncservice -->> santactl: "didReceiveLog (final messages)"
|
santad is triggering the sync service to start in SNTApplication (if a sync server URL is set), this is needed to have push notifications to work and (if I'm not mistaken) perform syncs on interval when needed. |
PTAL Thanks @mlw for the comment about dispatching syncs onto a queue. That simplified things a lot. Some additional refactoring was needed due to the serialization. Two new classes There are two non-blocking TODOs. Copying them here for visibility. From
From
|
Santa's syncing architecture is currently based around a user centric command line application (
santactl sync
). Over the years we have daemon-ized portions ofsantactl
to support features like push notifications and bundle voting. This works but added significant complexity to santactl. This pull request attempts to right this past wrong by splitting out all the syncing code into a separate service.The
syncservice
is a new binary/process that is launched on demand as a MachService. If a sync server is configured,syncservice
will start up and perform periodic syncs, handle push notifications and handle event and bundle uploads fromsantad
. Some highlights:santactl
tosyncservice
. The bulk of that work was completed in santasyncservice: move sync code to the santasyncservice dir #696 and is now finished in this pull.syncservice
is started by launchd, as opposed to the previous approach ofsantad
execingsantactl sync
.santactl sync
now communicates directly with thesyncservice
to sync.syncservice
. Thesyncservice
ensures concurrent syncs do not happen.Fixes #653