如何异步运行缓慢运行的批处理,特别是 SVN 提交后?

发布于 2024-11-04 05:11:05 字数 1367 浏览 4 评论 0原文

我有一个运行缓慢的批处理文件,它编译更改日志,然后向用户发送电子邮件。我希望它不会导致用户的提交在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩于岁月 2024-11-11 05:11:05

尝试在单独的进程中启动真正的钩子脚本:

@ECHO OFF
cmd.exe /c START %1\hooks\email-changes.bat %1 %2
echo 'fired' > %1\hooks\test.log

如果这不起作用,请找到一个可以在单独的进程/线程中启动另一个bat文件的工具。

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

if that doesn't work, find a tool that can start another bat file in a separate process/thread.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文