连续的WebJob会自动停止

时间:2015-02-13 15:15:58

标签: azure azure-webjobs azure-webjobssdk

我有一个与网站相关联的Webjob,它被配置为连续运行,它所做的只是查看消息的队列并处理它。

我的网站处于共享模式,目前几乎没有任何流量,因此我设置了虚拟服务,每隔1分钟请求主页,以防止网站被关闭作为此测试的一部分,并且接缝按预期工作,我可以注意到网站本身没有关闭。但是,除非我转到Azure管理门户并查找webjob状态,否则此webjob将在大约一小时内保持关闭状态。那一刻我去那里再次启动,然后在几分钟到一个小时内关闭。

此webjob的日志文件显示如下:

[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

我可以看到我的网站仍在运行并将主页返回给我,但作业本身已停止。

现在,当我登录管理门户查找状态时,我可以在日志中看到:

[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

如果网站处于活动状态,我怎样才能确保Webjob处于活动状态?或者至少使网站在回到运行状态时启动webjob。

更新1

我的webjob本身非常简单,如下所示:

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

并且触发器功能看起来像这样:

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

我需要做些什么来表明这项工作应该遵循网站的生命周期,即每次网站启动时启动。

更新2

我试着查看Process Explorer,当WebJobs停止时,我看到了三件事之一。我不知道如何在不进入管理门户的情况下查看作业日志,因此此时不知道实际日志。

Sometimes this Sometimes I see this enter image description here

但我确信Job没有运行,因为它没有处理来自队列的任何消息,直到我进入管理门户。

pingdom结果如下所示,表明网站本身正在运行而没有任何中断: Ping Dom Result

此致 基兰

2 个答案:

答案 0 :(得分:19)

如果您要按照共享模式运行,则会出现此类行为。如果您有持续运行的webjob,建议您打开始终开启。但是,这是 Basic Standard 的一项功能,因此您需要更改模式或重新考虑解决方案。

另外,请注意this link所做的这些注释。

enter image description here

enter image description here

答案 1 :(得分:0)

网络营销因网站关闭而停止。在日志中,您有以下行:

[02/13/2015 10:20:35 > 4660f6: SYS INFO] WebJob is stopping due to website shutting down
相关问题