如何运行缓慢运行的批处理异步,特别是一个SVN提交后? [英] How do I run a slow running batch Asynchronously, specifically a SVN post-commit?
问题描述
我已经编译更改日志,然后电子邮件用户的运行缓慢批处理文件。我想它不会引起用户的提交在TortoiseSVN的执行速度很慢。
I have a slow running batch file that compiles a log of changes and then emails a user. I would like it not to cause the user's commits to perform slowly in TortoiseSVN.
@ECHO OFF
SET REPOS=%1
SET REV=%2
SET DIR=%REPOS%/hooks
SET PATH=%PATH%;%DIR%;C:\Utils
SET WORKING_COPY=C:\path\to\local\copy\
SET SITENAME=MySiteName
SET SMTP_SERVER=11.11.11.11
SET EMAIL_TO=my@email.email
SET EMAIL_FROM=my@email.email
SET SUBJECT=SVN Update - %SITENAME% - rev %REV% - %REPOS%
svn cleanup %WORKING_COPY%
svn update %WORKING_COPY%
ECHO The following changes were made to the code: > %DIR%/email.txt
ECHO. >> %DIR%/email.txt
svn log %WORKING_COPY% -v -r "%REV%" >> %DIR%/email.txt
svn diff %WORKING_COPY% -c "%REV%" --no-diff-deleted >> %DIR%/email.txt
sendEmail -s %SMTP_SERVER% -t %EMAIL_TO% -f %EMAIL_FROM% -u "%SUBJECT%" -o message-file=%DIR%/email.txt
我意识到,这是运行缓慢,所以我把它移到另一个文件电子邮件changes.bat,并创建了一个简单的批处理异步调用此批。
I realised that this was running slowly, so I moved it to another file "email-changes.bat" and created a simple batch to call this batch asynchronously.
@ECHO OFF
#START %1\hooks\email-changes.bat %1 %2
echo 'fired' > %1\hooks\test.log
如果我注释掉它运行瞬间完成了START行。如果我删除评论它永远来完成。我认为应该允许提交后快速返回到SVN。
If I comment out the "START" line it runs and finishes instantly. If I remove the comment it takes forever to complete. I thought that should allow the post-commit to return to SVN quickly.
有什么办法,我可以得到code到不挂颠覆,但仍完成任务发送电子邮件的背景是什么?
Is there any way I can get the code to not hang in Subversion, but still complete the emailing task in the background?
推荐答案
试着在一个单独的进程开始真正的钩子脚本:
Try starting the real hook script in a separate process:
@ECHO OFF
cmd.exe /c START %1\hooks\email-changes.bat %1 %2
echo 'fired' > %1\hooks\test.log
如果不工作,找一个工具,可以在一个单独的进程/线程启动另一个bat文件。
if that doesn't work, find a tool that can start another bat file in a separate process/thread.
这篇关于如何运行缓慢运行的批处理异步,特别是一个SVN提交后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!