Mono MVC2应用程序用于从浏览器备份PostgreSql数据库。
经过一段时间的工作异常发生了线程中断(整个错误信息在下面)。 pg_dump运行但看起来已中止。 apache error_log包含以行中间结尾的输出。
如何从PostgreSql数据库创建备份副本哪个副本可以通过互联网从浏览器保存?
将mod_mono与Apache一起使用
安德鲁斯。
[Authorize]
public class BackupController : ControllerBase
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Backup()
{
var pinfo = new ProcessStartInfo();
var fn = "backup.backup";
pinfo.Arguments = " -ib -Z6 -f \"" + fn + "\" -Fc -h \"" + "myserver" + "\" -U \"" +
"postgres" + " \"" + "mydb" + "\"";
pinfo.FileName = "/usr/bin/pg_dump";
pinfo.UseShellExecute = false;
using (var process = new Process())
{
process.EnableRaisingEvents = true;
process.StartInfo = pinfo;
process.Start();
while (!process.HasExited)
Thread.Sleep(2000);
process.WaitForExit();
if (process.ExitCode!=0)
throw new Exception("error");
process.Close();
}
Response.ClearContent();
Response.WriteFile(fn);
Response.End();
System.IO.File.Delete(fn);
return null;
}
}
结果:
Server Error in '/myapp' Application
--------------------------------------------------------------------------------
Thread was being aborted
Description: HTTP 500. Error processing request.
Stack Trace:
System.Threading.ThreadAbortException: Thread was being aborted
at System.Web.HttpApplication.async_handler_complete_cb (IAsyncResult ar) [0x0002d] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.Web/System.Web/HttpApplication.cs:1010
at System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[System.Web.Mvc.Async.AsyncVoid].Begin (System.AsyncCallback callback, System.Object state, Int32 timeout) [0x00000] in <filename unknown>:0
at System.Web.Mvc.Async.AsyncResultWrapper.BeginSynchronous[AsyncVoid] (System.AsyncCallback callback, System.Object state, System.Func`1 func, System.Object tag) [0x00000] in <filename unknown>:0
at System.Web.Mvc.Async.AsyncResultWrapper.BeginSynchronous (System.AsyncCallback callback, System.Object state, System.Action action, System.Object tag) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContextBase httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContext httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback cb, System.Object extraData) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator6.MoveNext () [0x00d42] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.Web/System.Web/HttpApplication.cs:1365
at System.Web.HttpApplication.Tick () [0x00000] in /usr/src/redhat/BUILD/mono-2.10.2/mcs/class/System.Web/System.Web/HttpApplication.cs:932
--------------------------------------------------------------------------------
Version information: Mono Runtime Version: 2.10.2 (tarball Mon Apr 18 18:57:39 UTC 2011); ASP.NET Version: 2.0.50727.1433