简体   繁体   English

imagemagick转换CPU错误

[英]imagemagick convert CPU bug

I'm running Imagemagick's convert function within a shell script, called via apache/python script. 我正在通过apache / python脚本调用的Shell脚本中运行Imagemagick的convert函数。 It usually works fine, but now and then the CPU of the server maxes out and does not come back down. 它通常可以正常工作,但是服务器的CPU有时会达到极限,并且不会恢复正常。 Here is the print out of 'top': 这是“顶部”的打印输出:

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
9672 apache    20   0  357m 1452  640 R 52.9  0.1 223:44.88 convert            
9457 apache    20   0  294m 161m  648 R 47.1  9.8 222:50.15 convert  

What can I do to 1. safeguard against this 2. kill the process? 我该怎么做1.防止这种情况2.终止进程? If I do not manually kill the processes, they idle indefinitely, bring the server to a halt. 如果我不手动终止进程,则它们将无限期空闲,从而使服务器停止运行。

You have a couple of options but the right answer depends on your particular situation. 您有两种选择,但是正确的答案取决于您的具体情况。

You may with to use one of the subprocess commands from Python, and then terminate jobs that are taking too long. 您可能会使用Python的子过程命令之一,然后终止耗时太长的作业。 If you are just issuing a simple shell command, you might like to see if the "timeout" utility is available for your OS and distribution. 如果您只是发出一个简单的shell命令,则可能希望查看“超时”实用程序是否可用于您的操作系统和发行版。

Beyond that you might want to look at decoupling the image processing from your web serving infrastructure. 除此之外,您可能还需要考虑将图像处理与Web服务基础结构分离。

Finally, it is probably a good idea to post what options your are invoking "convert" with. 最后,发布调用“转换”的选项可能是一个好主意。 There may be some folks who know enough to point out obvious problems with your approach with that tool. 可能有些人知道得足够多,可以指出您使用该工具的方法存在明显的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM