Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 25, 2012 11:56 AM by kobruleht
Member
589 Points
463 Posts
Mar 25, 2012 11:56 AM|LINK
Code below is used for backup. pg_dump never finishes, cpu usage is 0%. If line
process.StartInfo.RedirectStandardError = true;
is removed, code works ok but error result cannot captured. It looks like deadlock.
How to get error info writtent to stderr by pg_dump ?
[Authorize] public class BackupController : ControllerBase { [AcceptVerbs(HttpVerbs.Get)] public FileStreamResult Backup() { var process = new Process(); process.StartInfo.FileName = "c:\\Program Files\\PostgreSql\\9.1\\bin\\pg_dump.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; // todo: why if this line is present, pg_dump never finishes process.StartInfo.RedirectStandardError = true; process.EnableRaisingEvents = true; process.Exited += (sender, e) => { Writelog( process.StandardError.ReadToEnd() ); }; Server.ScriptTimeout = 1 * 60 * 60; process.Start(); return new FileStreamResult(process.StandardOutput.BaseStream, "application/backup"); } }
kobruleht
Member
589 Points
463 Posts
How to capture process StandardError stream in controller
Mar 25, 2012 11:56 AM|LINK
Code below is used for backup. pg_dump never finishes, cpu usage is 0%. If line
process.StartInfo.RedirectStandardError = true;
is removed, code works ok but error result cannot captured. It looks like deadlock.
How to get error info writtent to stderr by pg_dump ?
[Authorize] public class BackupController : ControllerBase { [AcceptVerbs(HttpVerbs.Get)] public FileStreamResult Backup() { var process = new Process(); process.StartInfo.FileName = "c:\\Program Files\\PostgreSql\\9.1\\bin\\pg_dump.exe"; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; // todo: why if this line is present, pg_dump never finishes process.StartInfo.RedirectStandardError = true; process.EnableRaisingEvents = true; process.Exited += (sender, e) => { Writelog( process.StandardError.ReadToEnd() ); }; Server.ScriptTimeout = 1 * 60 * 60; process.Start(); return new FileStreamResult(process.StandardOutput.BaseStream, "application/backup"); } }