简体   繁体   English

Azure Web作业失败-剩余ReadLine()

[英]Azure Web Jobs failure - ReadLine() left in

So I created an Azure Web Job that performs a certain task every 15 mins. 因此,我创建了一个Azure Web作业,每15分钟执行一次特定任务。 It runs a C# console application. 它运行一个C#控制台应用程序。 The problem is that on my last upload of my program I left my Console.ReadLine(); 问题是,在我最后一次上传程序时,我离开了Console.ReadLine(); argument in, causing the program to never finish (used for local debugging of course) and the web job to fail and never run again. 参数,导致程序永不结束(当然用于本地调试),并且Web作业失败并且永不再次运行。 This can obviously be fixed real quick if I had the source code, but the source code is at my office, which I forgot to upload to my cloud storage. 如果有源代码,这显然可以很快解决,但是源代码在我的办公室,我忘了上传到云存储中。 I won't have access to it till a bit later on this week. 在本周晚些时候,我将无法使用它。

So I'm looking for a quick fix. 因此,我正在寻找快速解决方案。 I can download the .exe program that was last uploaded easily. 我可以下载最近轻松上传的.exe程序。 So now what I'm thinking is to run another program first that calls my main program and then closes it after a certain time. 所以现在我在想的是先运行另一个程序,该程序调用我的主程序,然后在一定时间后关闭它。 I tried a simple .bat script that was able to successfully open the program, but it couldn't close/kill the process due to access denied errors (worked locally). 我尝试了一个简单的.bat脚本,该脚本能够成功打开该程序,但是由于访问被拒绝的错误(在本地工作),它无法关闭/杀死该进程。 Any other quick suggestions that'll work in a web job environment? 还有其他可以在网络工作环境中使用的快速建议吗?

Obviously if you see this here in a few days, I've probably already made corrections to the source code at the root of the issue, but others may be interested as well. 显然,如果您几天后在这里看到此消息,那么我可能已经在问题的根源上对源代码进行了更正,但是其他人也可能对此感兴趣。 :) :)

UPDATE: 更新:

Thank you to everyone! 谢谢大家! Each of these solutions helped me to get my web job running as intended. 这些解决方案中的每一个都帮助我按计划运行了Web工作。 The decompiling using Reflector was especially useful so that I can add this project to the cloud like its suppose to be. 使用Reflector进行反编译特别有用,因此我可以像预期的那样将该项目添加到云中。 However, using the run.cmd as suggested by @evilSnobu was the easiest and simplest way to apply a workaround as requested in my question. 但是,按照@evilSnobu的建议使用run.cmd是应用我的问题中要求的解决方法的最简便方法。

Again thank you! 再次谢谢你! :) :)

PS I switched from Console.ReadLine() ; PS我从Console.ReadLine()切换; to System.Threading.Thread.Sleep(); System.Threading.Thread.Sleep(); to prevent any future mishaps. 以防止将来发生任何意外。

public class Program
    {
        public static void Main()
        {
            Console.WriteLine("Hello World!");
            Console.ReadLine();
            Console.WriteLine("After ReadLine");
        }
    }

Try running your Webjob as echo '\\n' | helloconsole.exe 尝试将Webjob运行为echo '\\n' | helloconsole.exe echo '\\n' | helloconsole.exe

Testing in Kudu: 在Kudu中进行测试:

D:\home\tmp>echo '\n' | helloconsole.exe
Hello World!
After ReadLine

D:\home\tmp>echo '\n' | helloconsole.exe
Hello World!
After ReadLine

..seems to pull it off. ..似乎要把它拉下来。

If you drop that in run.cmd it will have precedence over your .exe binary. 如果将其放在run.cmd ,它将优先于您的.exe二进制文件。 https://github.com/projectkudu/kudu/wiki/Web-jobs https://github.com/projectkudu/kudu/wiki/Web-jobs

We use the following logic to decide which file is the script to run within the job's directory: 我们使用以下逻辑来确定要在作业目录中运行的脚本是哪个文件:

  • Per file type we look first for a file named: run.{file type extension} (for example run.cmd or run.exe). 对于每种文件类型,我们首先查找名为: run.{file type extension} (例如run.cmd或run.exe)。

Try the following command to kill the process: 尝试使用以下命令杀死该进程:

d:\devtools\sysinternals\pskill /accepteula YourProcessName

You can practice running this in Kudu Console first. 您可以先练习在Kudu控制台中运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM