Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I wondered if there was some way of triggering uSync import via a public url or if not is there an API I could use to create my own endpoint to do this?
What I am trying to achieve is adding a Url to my deployment script.
The idea is once I've done a deployment I would trigger a url which would then automatically run the update.
I understand there are some settings to set this going at start up but I don't really want to do this every time there is an IIS restart etc. I would be great if I could just trigger this the once without having to log into the backend and trigger this manually.
Thanks in advanced.
What I've done successfully in the past is to add a usync.stop file after the deployment is successful.
Then your lovely usync changes are imported but for future restarts the site skips any overhead.
It's just a simple text file in the usync directory. Worked a treat!
There was also usync.once - add this and it runs once and renames to .stop
I think this is still in the current version.
As Steve says usync.once will do a single sync, so you can have it happen only the first time.
There is no public (unauthenticated) end point, (you don't want random's resyncing your site!). but you could add one,
You could take code for the authenticated API controller (the one the dashboard uses). and put this in your own controller. ?
public IEnumerable<uSyncAction> Import(uSyncOptions options)
var hubClient = new HubClientService(options.ClientId);
return uSyncService.Import(settings.RootFolder, options.Force, new SyncHandlerOptions()
Group = options.Group
of the options here:
I would personally put some authentication around that (maybe a shared key/id or something in the api call?).
Thanks for getting back to me so quickly.
Some good solutions.
Kevin I was actually thinking the same. I sort of found this endpoint in the packages folder in one of the angularJs files. I was planning on jumping on the top of that. But yeah I was unsure what the options were.
Thanks for explaining.
I get you about the public URL. I was thinking the same. I would create some kind of auth. Even if just an encrypted query string or something.
Do you know where I might find the client Id?
I think this is the only bit I am unsure about.
you don't need the clientId it is the internal id signalR uses when connecting to a browser to send messages - so unless you have a signalR end point you want to get the update messages for, you can choose not to create the hub and pass null for the callbacks.
if you do want signalR - well it gets complex but uSync's code is here.
and a slightly tidier implimentation for reference is here.
Perfect. I will give this a go.
Thanks Kevin, Steve
What I probably wasn't clear about is that usync.once file is added as part of the deployment. So no messing about having to remember to add this file to sourcecode, just create it in your deployment script - it's so simple I forgot we'd even did it.
I think you're over complicating things with API calls.. unless I'm missing something complicated about your setup? When you do a deployment you'd want your usync changes to run on startup before your new code starts firing...?
And, as usual, great stuff from Kevin here.
In that case your solution sounds great.
If its just a point of adding this into the deployment then that is fine.
I will also give this a go.
Thanks - not really my solution. It's Kevin's - he built the logic after all :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted