如何异步运行缓慢运行的批处理,特别是 SVN 提交后?
我有一个运行缓慢的批处理文件,它编译更改日志,然后向用户发送电子邮件。我希望它不会导致用户的提交在 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 protected]
SET [email protected]
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
我意识到它运行缓慢,因此我将其移动到另一个文件“email-changes.bat”并创建一个简单的批处理来异步调用该批处理。
@ECHO OFF
#START %1\hooks\email-changes.bat %1 %2
echo 'fired' > %1\hooks\test.log
如果我注释掉“START”行,它会立即运行并完成。如果我删除评论,则需要永远完成。我认为这应该允许提交后快速返回到 SVN。
有什么方法可以让代码不挂在 Subversion 中,但仍然在后台完成电子邮件发送任务?
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 protected]
SET [email protected]
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
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
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.
Is there any way I can get the code to not hang in Subversion, but still complete the emailing task in the background?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在单独的进程中启动真正的钩子脚本:
如果这不起作用,请找到一个可以在单独的进程/线程中启动另一个bat文件的工具。
Try starting the real hook script in a separate process:
if that doesn't work, find a tool that can start another bat file in a separate process/thread.