Running CRON jobs against wisej app

0
0

Hi Everyone,

I’ve got a wisej app running on an externally hosted 3rd party IIS server.  I need to periodically run/load a page in the app so that it triggers a bunch of checks to carry out based on timed events.  I was thinking along the lines of running a CRON job.  I don’t have my own Windows server nor an ‘always-on’ machine, but I do have a Synology NAS device that can run scheduled python or shell scripts (ash linux).  I checked with the IIS hosting company that I’m using and they will only run a scheduled task every 20 minutes, but I need it to run at least every 5 minutes.

Anyway, I threw together some python using ‘httplib’ module to load the html page that I thought would run the wisej application, but it doesn’t appear to work.  Tried a similar thing with shell script using ‘wget’, which only downloads the html page structure but doesn’t actually start the app.  After a couple of days trying various python and shell scripts and nothing working, I found a website called cron-job.org that is supposed to trigger a page load of your choosing at a set time/interval, but that doesn’t work either.

So, I’m not sure where to go from here or if my approach is completely wrong or not.  If I had a spare windows machine kicking around then this sort of scheduled task would be a cinch, but such is life!

Has anybody tackled this sort of problem before and if so, what approach do you use?

Thank you in advance!

  • You must to post comments
0
0

Sorry I didn’t reply sooner. Just requesting the HTML page will not work. All you get back is the HTML page. The requester (which is usually the browser) has to execute javascript. It’s the same for all javascript web apps. If you request a page with angular or jquery all you get back is the page with the links.

It’s a lot better to start the process using server code and don’t rely on an external timer or requester. You build a simple monitor app in Wisej and launch threads or processes and manage them. The third party IIS allows you launch threads.

The only issue is that when IIS recycles it will kill the threads in the same app pool. I believe it can be turned off for a specific app pool.

Best,

Luca

  • Luca (ITG)
    Another thing you can do is launch the process using as aspx page. That one will be executed on the server when requested,
  • Andrew Hills
    Hi Luca, I tried the aspx page approach, still same result. From my Synology NAS it runs the python script no problem but I can see in my logging in the wisej app that nothing gets launched. The other method that you suggested, using a thread/monitor on the server, this was actually my first approach but as soon as the browser is closed the session ends along with the thread. Unfortunately I can’t change the thread recycle times on IIS due to the host i’m using blocks that level of access. I think the only option left is to purchase another computer that I can keep logged into the app all the time so it can run those periodical tasks.
  • edmond girardi
    I would think that calling a .ASPX page with URL parameters for the task to kick off should work – sniffing out the URL param when ASPX page loads.
  • Andrew Hills
    Hi Edmond, if I launch the ASPX url within windows using Chrome or another browser then yes it works, just not from the Synology device.
  • You must to post comments
0
0

Why not just call a url on your WiseJ site from Python with a URL parameter – different values for the different tasks

Read the parameter – there were a few examples in the posts, and depending on tthe value of the parameter – do different things.

  • Andrew Hills
    Hi Edmond, I setup a HTML page in my wisej app that I can call with a few parameters and this all works if I do this manually using Chrome/IE/FF but if I call the same URL with the same parameters from a python or shell script the wisej code never gets triggered. All the python or shell script will do is download the html page structure. I’m thinking that perhaps wisej needs some sort of interactive session running in a browser before it will work properly.
  • edmond girardi
    You need to execute an HTTP GET – not download the page resources. Have a look at this this should work: https://stackoverflow.com/questions/4476373/simple-url-get-post-function-in-python
  • Andrew Hills
    Thanks for locating that info Edmond. I tried each of the ideas listed on there but no go. It was worth a try!
  • edmond girardi
    Put some logging in your Wise J App page that parses out the url parameters and write to a log file – make sure you are even getting to the page and that the parameters are getting there. You can also check the IIS logs to make sure that you see the “GET” with all the parameters – check that the URL parameters are formatted correctly. I.E: “?param1&param2”
  • You must to post comments
0
0

Hi Andrew,

I think a scheduled task will do as long as it runs a batch file like

“\Program Files (x86)\Google\Chrome\Application\chrome.exe” wisej.com

  • Andrew Hills
    Hi Tiago, Thanks for the suggestion. Unfortunately I don’t have a spare windows machine that I can leave switched on to do this scheduled task, only my development laptop and I need to have this task running all the time.
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.