vB-5.4.3: Hooks: run in parallel?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • m97forum
    Member
    • Jun 2017
    • 54
    • 5.3.x

    vB-5.4.3: Hooks: run in parallel?

    Hello,

    I'm thinking about extending my vB-5.4.3 installation using the hookFrontendContentAfterAdd-hook. Apart from it is not documented: if this hook gets called and the operation defined by my imlementation takes some time to be processed, does the user have to wait for my operation to complete? Or is that done in the background? What is the recommended way to handle such situations?
    I dont want the user to wait for my process to complete...

    Thanks a lot.
    Stefan
  • glennrocksvb
    Former vBulletin Developer
    • Mar 2011
    • 4011
    • 5.7.X

    #2
    I responded to you about this on my site.

    Hi there, I'm running a vB 5.4.3 installation here. The idea is to catch a new post to a forum by some user and forward it to a Whatsapp group (using something

    Flag Icon Postbit Insert GIPHY Impersonate User BETTER INITIALS AVATAR Better Name Card Quote Selected Text Bookmark Posts Post Footer Translate Stop Links in Posts +MORE!

    Comment

    • m97forum
      Member
      • Jun 2017
      • 54
      • 5.3.x

      #3
      Hello again,

      I tried pthread + cUrl - but that didn't work out. Now, here's another approach:

      When the page (any page, as far as I know) gets loaded/processed/whatever, vB runs certain processes in the background before or after page usage. This "load" also leads to the various cronjobs defined be run.
      Do you know, how I can add a file/function/hook, such that it will be run, each time the page gets hit?

      I will probably just write the content received by the addContent-hook to the database and let the background process do the actual processing.

      I will also try to add my stuff as a cronjob, but that's just additional (since this would run just every 5 minutes).

      Thanks a lot

      Stefan

      Comment

      • Wayne Luke
        vBulletin Technical Support Lead
        • Aug 2000
        • 73981

        #4
        The Scheduled Task system will only run one task per page load in order to reduce the impact on the end user. If you need to run tools more frequently, we recommend using the vbcron.php file in the do_not_upload folder. Configuration information is in the comments within the file.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API

        Comment

        • m97forum
          Member
          • Jun 2017
          • 54
          • 5.3.x

          #5
          Wayne,

          that's too rare. My hosting provider lets me run cron just every 5th minute. Which would result in quite extensive waiting times for the message to be delivered.
          Is there a way I can open a (Json, whatever) Interface to the internal site, such that I can call it internally with a async call? Of cource, I can keep it completely outside of vB, but that would make installation a pain.

          And: what do I need to do to add my sender to the list of tasks to be performed at each page load?


          Thanks.
          Stefan

          Comment

          • Wayne Luke
            vBulletin Technical Support Lead
            • Aug 2000
            • 73981

            #6
            You cannot trigger scheduled tasks via AJAX Requests. However, you can perform a proper login via AJAX and send requests to the API from any script. If you extend the API via extensions with a method that you can call, then you would be able to do this via an async call.

            To see how a scheduled task is coded, you would need to look at the scripts in the /core/includes/cron folder. Once you have a script and have uploaded it to that folder, you can add it to the scheduled tasks list via the AdminCP under Scheduled Tasks -> Add New Scheduled Task. If you cannot see the Add New Scheduled Task link, put your site into debug mode.
            Translations provided by Google.

            Wayne Luke
            The Rabid Badger - a vBulletin Cloud demonstration site.
            vBulletin 5 API

            Comment

            • m97forum
              Member
              • Jun 2017
              • 54
              • 5.3.x

              #7
              Hey,
              well, sending an async AJAX request seems to be the way to go.
              What do I need to do, to have vB export an interface, that I can call? What does that method need to look like? Do I need to "register" it anywhere? Can I restrict access to it in any way?

              Thanks.
              Stefan

              Comment

              Related Topics

              Collapse

              Working...