Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

continuous WebJob stops automatically

I have an Webjob associated with the Website that is configured to run continuously and all it does is watches a queue for a message and process it.

My website is in a shared mode and hardly has any traffic at the moment so I have set up dummy service that is requesting the home page every 1 min to keep the website from being shut down as part of this testing, and that seams to work as expected and I can notice that website itself is not shutdown. however this webjob keeps shutting down in about an hour unless I go to the Azure Management portal and look for the webjob status. Moment I go there it starts up again and then shuts down in few minutes to an hour.

the log file for this webjob shows something like this:

[02/13/2015 09:19:45 > 4660f6: INFO] Job host started
[02/13/2015 10:19:41 > 4660f6: SYS INFO] WebJob is still running
[02/13/2015 10:20:35 > 4660f6: SYS INFO] WebJob is stopping due to website shutting down
[02/13/2015 10:20:35 > 4660f6: SYS INFO] Status changed to Stopping
[02/13/2015 10:20:35 > 4660f6: INFO] Job host stopped
[02/13/2015 10:20:35 > 4660f6: SYS INFO] Status changed to Success
[02/13/2015 10:20:35 > 4660f6: SYS INFO] Status changed to Stopped

I can see that my website is still running and returning me the home page, but job itself is stopped.

now when i log in to the management portal to look for the status I can see this in the logs:

[02/13/2015 10:20:35 > 4660f6: SYS INFO] Status changed to Success
[02/13/2015 10:20:35 > 4660f6: SYS INFO] Status changed to Stopped
[02/13/2015 14:56:15 > 4660f6: SYS INFO] Status changed to Starting
[02/13/2015 14:56:17 > 4660f6: SYS INFO] Run script 'WebJobs.exe' with script host - 'WindowsScriptHost'
[02/13/2015 14:56:17 > 4660f6: SYS INFO] Status changed to Running
[02/13/2015 14:56:19 > 4660f6: INFO] Found the following functions:
[02/13/2015 14:56:19 > 4660f6: INFO] WebJobs.NotificationsProgram.ProcessQueueMessage
[02/13/2015 14:56:19 > 4660f6: INFO] WebJobs.NotificationsProgram.PublishNotification
[02/13/2015 14:56:19 > 4660f6: INFO] WebJobs.NotificationsProgram.ProcessMessages
[02/13/2015 14:56:19 > 4660f6: INFO] Job host started

Any ideas as to how can I make sure that the Webjob is active as long as the website is active? or at least to make that the website starts the webjob as well when it comes back to the running state.

UPDATE 1

My webjob itself is a very simple one as shown below:

static void Main(string[] args)
{
    JobHost host = new JobHost();
    host.RunAndBlock();
}

and the trigger functions looks close to like this:

public static void WriteLogPOCO([QueueTrigger("logqueue")] BlobInformation blobInfo, TextWriter logger)
{
    logger.WriteLine("Queue message refers to blob: " + blobInfo.BlobName);
}

is there something I have to do here to indicate that this job should follow the lifecycle of the website, i.e. start up every time the website is started.

UPDATE 2

I tried to look at the Process Explorer and I see one of the three things when the WebJobs are stopped. I don't know how to see the job logs without going to the Management portal, so don't know the actual logs at this point in time.

Sometimes thisSometimes I see thisenter image description here

But I am sure that the Job is not running as its not processing any messages from the queue till I go to the management portal.

the pingdom result as shown below which shows that the website itself is running without any break: Ping Dom Result

Regards Kiran

like image 625
Kiran Avatar asked Feb 13 '15 15:02

Kiran


People also ask

When would you use a WebJob?

You can use the WebJobs feature of App Service to run a script or code in the context of an App Service web app. The WebJobs SDK is a framework designed for WebJobs that simplifies the code you write to respond to events in Azure services.


1 Answers

This kind of behavior is expected if you're going to be running in Shared mode as you are. It is recommended that you turn on Always On if you have a continuously running webjob. However, this is a feature of Basic and Standard so you will need to change your mode or rethink your solution.

Also, be aware of these notes made from this link.

enter image description here

enter image description here

like image 118
Rick Rainey Avatar answered Sep 26 '22 05:09

Rick Rainey