- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我设置了一个 Windows 服务来管理自定义 .Net 任务。组织是:
-Windows 服务监控计划并根据需要启动工作程序 .exe。
-Worker .exe(轻量级 winform 应用程序)使用命令行参数来启动 DLL(插件)并运行一些代码。
这几个月来一直运作良好。我最近将它迁移到 Server 2012(从 2008 IIRC 开始)——这可能不相关,但很难说。迁移后一段时间以来,我遇到了一个问题,即 worker .exe 在被 process.start() 调用后“启动”,但没有到达我的代码。没有错误或任何错误,它似乎在应用程序加载期间卡住。
启动它的服务代码相当标准。
// Create a temp folder and copy the executable to it
// (so the source exe isn't always in use and can be swapped out)
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Path.Combine(temp.Path, Path.GetFileName(ExecutablePath));
psi.Arguments = CommandLineArgs.ConcatenateList(" ");
psi.UseShellExecute = false;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
psi.ErrorDialog = false;
psi.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo = psi;
p.Start();
// read standard output if necessary, kill and reschedule if appears to be frozen, etc.
此时,worker 可执行文件启动 - 它在任务管理器中看起来基本正常。唯一提示我出了问题的是内存消耗 - 在正常情况下,worker 在启动期间达到大约 5MB 并增长以反射(reflect)任务,但是当进程卡住时它只达到大约 2MB 并停止。
为了证明它不是我在 worker 中的任何代码,我在第一行添加了对日志记录函数的调用,但从未见过日志。
没有错误消息,而且——真正奇怪的是——这不是一个一致的问题。现在卡住的完全相同的调用将在 30 秒后正常运行。问题发生的时间似乎也没有任何真实模式 - 我看到的最接近的事情是它偶尔会同时发生在多个任务上(例如,它可能会影响在问题发生时开始的所有任务发生在任何任务中)。
我的服务可以自动检测并适当处理它,所以这不是一个紧急问题,但如果任何人都认为原因或解决方案突出,我仍然想解决这个问题。
worker 的初始化代码只是一个标准的 win 表单启动,我的东西开始在 form_load 中被调用。
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Do Stuff - never gets hit when the freeze happens.
}
编辑:根据评论,将服务设置为在看到挂起的进程时使用它创建的日志条目记录一个小型转储。明天会检查它,看看会发生什么。
2015 年 9 月 4 日编辑:小型转储信息:
小型转储显示代码停止/卡在 static void main 的退出},即:
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
} // <------ This is where the main thread is frozen.
否则一切似乎都很好。
为了以防万一,我将进行一些研究并尝试对 worker 进行一些更改。
编辑 2015 年 9 月 4 日 #2:调整了工作人员启动,它似乎正在工作。它的要点是删除表单引用并仅使用应用程序上下文(例如 codeproject sample )
我用任务请求重击了系统,但没有任何问题。我将让它在周末运行作为测试,并在周二进行状态更新。仍然很好奇为什么它会随着表单加载而随机中断。
现在的代码:
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new AppContext());
}
}
class AppContext : ApplicationContext
{
public AppContext()
{
// Do Stuff
}
}
最佳答案
我还不能在你的帖子上添加评论(我会因为这样做而被其他 stackoverflow 用户毁掉,但是......)
我遇到的问题和你的很相似。我的问题来自服务启动的 session 。在迁移期间,该服务在新操作系统的“ session 0”中启动,而不是作为“系统”程序启动。它是在我们的程序允许通过服务运行的情况下发布的。也许你应该检查这一点。
对不起,如果我把它作为一个答案而不是在评论中说出来
关于从 Process.Start() 调用时,C# 应用程序随机挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32384234/
我正在通过 labrepl 工作,我看到了一些遵循此模式的代码: ;; Pattern (apply #(apply f %&) coll) ;; Concrete example user=> (a
我从未向应用商店提交过应用,但我会在不久的将来提交。 到目前为止,我对为 iPhone 而非 iPad 进行设计感到很自在。 我了解,通过将通用PAID 应用放到应用商店,客户只需支付一次就可以同时使
我有一个应用程序,它使用不同的 Facebook 应用程序(2 个不同的 AppID)在 Facebook 上发布并显示它是“通过 iPhone”/“通过 iPad”。 当 Facebook 应用程序
我有一个要求,我们必须通过将网站源文件保存在本地 iOS 应用程序中来在 iOS 应用程序 Webview 中运行网站。 Angular 需要服务器来运行应用程序,但由于我们将文件保存在本地,我们无法
所以我有一个单页客户端应用程序。 正常流程: 应用程序 -> OAuth2 服务器 -> 应用程序 我们有自己的 OAuth2 服务器,因此人们可以登录应用程序并获取与用户实体关联的 access_t
假设我有一个安装在用户设备上的 Android 应用程序 A,我的应用程序有一个 AppWidget,我们可以让其他 Android 开发人员在其中以每次安装成本为基础发布他们的应用程序推广广告。因此
Secrets of the JavaScript Ninja中有一个例子它提供了以下代码来绕过 JavaScript 的 Math.min() 函数,该函数需要一个可变长度列表。 Example:
当我分别将数组和对象传递给 function.apply() 时,我得到 NaN 的 o/p,但是当我传递对象和数组时,我得到一个数字。为什么会发生这种情况? 由于数组也被视为对象,为什么我无法使用它
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界. 这篇CFSDN的博客文章ASP转换格林威治时间函数DateDiff()应用由作者收集整理,如果你
我正在将列表传递给 map并且想要返回一个带有合并名称的 data.frame 对象。 例如: library(tidyverse) library(broom) mtcars %>% spl
我有一个非常基本的问题,但我不知道如何实现它:我有一个返回数据框,其中每个工具的返回值是按行排列的: tmp<-as.data.frame(t(data.frame(a=rnorm(250,0,1)
我正在使用我的 FB 应用创建群组并邀请用户加入我的应用群组,第一次一切正常。当我尝试创建另一个组时,出现以下错误: {"(OAuthException - #4009) (#4009) 在有更多用户
我们正在开发一款类似于“会说话的本”应用程序的 child 应用程序。它包含大量用于交互式动画的 JPEG 图像序列。 问题是动画在 iPad Air 上播放正常,但在 iPad 2 上播放缓慢或滞后
我关注 clojure 一段时间了,它的一些功能非常令人兴奋(持久数据结构、函数式方法、不可变状态)。然而,由于我仍在学习,我想了解如何在实际场景中应用,证明其好处,然后演化并应用于更复杂的问题。即,
我开发了一个仅使用挪威语的应用程序。该应用程序不使用本地化,因为它应该仅以一种语言(挪威语)显示。但是,我已在 Info.plist 文件中将“本地化 native 开发区域”设置为“no”。我还使用
读完 Anthony's response 后上a style-related parser question ,我试图说服自己编写单体解析器仍然可以相当紧凑。 所以而不是 reference ::
multicore 库中是否有类似 sapply 的东西?还是我必须 unlist(mclapply(..)) 才能实现这一点? 如果它不存在:推理是什么? 提前致谢,如果这是一个愚蠢的问题,我们深表
我喜欢在窗口中弹出结果,以便更容易查看和查找(例如,它们不会随着控制台继续滚动而丢失)。一种方法是使用 sink() 和 file.show()。例如: y <- rnorm(100); x <- r
我有一个如下所示的 spring mvc Controller @RequestMapping(value="/new", method=RequestMethod.POST) public Stri
我正在阅读 StructureMap关于依赖注入(inject),首先有两部分初始化映射,具体类类型的接口(interface),另一部分只是实例化(请求实例)。 第一部分需要配置和设置,这是在 Bo
我是一名优秀的程序员,十分优秀!