Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

azure - 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 this Sometimes I see this enter 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...