Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 10, 2013 @ 17:48
    Anthony Dang
    0

    Programatically disable uSync

    Possibly an odd request.

    I'm just wondering if it's possible to programatically disable uSync after it has done it's magic of installing new doctypes, datatypes etc?

    The reason being that we want to provide new doctypes etc to a client, but have uSync disabled automatically so consequenting app starts are not slow.

     

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 10, 2013 @ 19:04
    Kevin Jump
    0

    with no changes

    you could change the config ? /config/usyncsettings.config. 

    Assuming it's for delivery only - you would have Read="true" and everything else set to false. 

    You could load the config and then change this to "false" once the data types are delivered ? 

    Possible things i could enhance

    uSync doesn't have a post load run code thing in it - but that might be an idea ? i could put in a IUSyncBase class with before and after delegates ? 

    you could then write a class that would trigger before and after usync ran. i might do that at some point ?

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 10, 2013 @ 19:24
    Anthony Dang
    0

    "You could load the config and then change this to "false" once the data types are delivered ? "

    Yeah the question is how do I hook into that? Would I have to bind to each "new" event? That woudl be messy.

    "i could put in a IUSyncBase class with before and after delegates"

    That would definitely take care of it. 

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 10, 2013 @ 19:31
    Kevin Jump
    0

    Just poking around the umbraco core (to see how delegate stuff is done.... in short complex)

    There is a "WeightedPluginAttribute" class in Umbraco.Core.ObjectResolution, that i think is used someway to weight the execution of types (including IApplicationBase)

    defaultpluginweight appears to be 10 in Umbraco.Core.ObjectResolution.ManyObjectsResolverbase. 

    uSync doesn't set this value - if you hooked into IApplicationEventHandler and weight your thing at 11 - it would fire after uSync?

    Option C: a usync version somewhere in a file, usync reads from disk, if the version matches it doesn't continue. just a question of where to store the version ? probibly in a datatype? 

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 10, 2013 @ 19:37
    Kevin Jump
    0

    Continued brain dump! 

    sync.once in the root of usync. 

    if present, usync renames to sync.stop at end of process. 

    if sync.stop is present no sync happens. 

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 10, 2013 @ 20:31
    Anthony Dang
    0

    Are you talking about the version table?

    Regarding events, you could create a before and after event. Just normal events. Nothing special.

    As a wild alternative... have usync set the "read" config to false after 1st load. As a developer, I would have to set it to false after it installs everythign anyway... otherwise my app start is 3mins.

     

     

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 10, 2013 @ 20:37
    Kevin Jump
    0

    i'm liking the usync.once and usync.stop file. it lets you deploy it with the files and without code. 

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 10, 2013 @ 20:46
    Anthony Dang
    0

    "it lets you deploy it with the files and without code. "

    What do you mean?

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 10, 2013 @ 20:49
    Kevin Jump
    0

    A 'deployment' could be 

    • Copy usync files
    • Copy / create a usync.once file
    • Restart app
    Usync would do the read then rename the .once file so all other starts wouldn't read
    Deployment stays as just a file copy.
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 11, 2013 @ 00:53
    Anthony Dang
    0

    Could that be acheived with a flag in the config?

     

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 29, 2013 @ 22:52
    Kevin Jump
    0

    latest version of uSync (1.2.0) has the usync.once file method in it. 

    if the usync folder has a file at the root called usync.once. then at the end of a read it will be renamed usync.stop.

    if their is a usync.stop file then the read will not happen at startup.

    I've also seperated out (but not tested in anyway!) the three primary functions of usync into public methods. 

    so in theory in umbraco (somewhere?) you could:

    jumps.umbraco.usync.uSync syncObj = new uSync();
    syncObj.ReadAllFromDisk();
    syncObj.SaveAllToDisk();
    syncObj.AttachToAll();

    not sure if you would ever want to.. but in theory you can, these functions when called like this ignore what the config file says, so you could in theory turn usync off and call it programatically - again i haven't actually tested this yet. 

    next step put in a usync.webservice.dll - but i might just wait a little while :) 

     

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    May 07, 2013 @ 11:41
    Anthony Dang
    0

    nice work!

     

Please Sign in or register to post replies

Write your reply to:

Draft