running a .sh file inside grails server
I am trying to run a bash file(.sh) to make some photos conversion in my grails server, my code is the following to make that task:
def folderTo = grailsAttributes.getApplicationContext().getResource("/files/").getFile()
def f = new File(folderFrom.toString())
def cmd = '/bin/bash /var/lib/tomcat6/webapps/malibueventapp-qa/uploads/convertPhoto.sh /var/lib/tomcat6/webapps/malibueventapp-qa/uploads /var/lib/tomcat6/webapps/malibueventapp-qa/files'
def process = runtime.exec(cmd, null, f);
the problem here is, when I am running it in the server, I am getting the follow error:
Cannot run program "/bin/bash" (in directory "/var/lib/tomcat6/webapps/malibueventapp-qa/uploads"): java.io.IOException: error=1开发者_StackOverflow社区2, Cannot allocate memory
that is the only message error i am getting! so I have no ideas what to do!
some sugestions?!
thanks
Sounds like you're not alone:
How to solve "java.io.IOException: error=12, Cannot allocate memory" calling Runtime#exec()?
Above SO thread provides a (possible) solution to your problem, give it a shot.
just to sum-up what I did!
I increased the swap memory: http://www.linux.com/learn/tutorials/442430-increase-your-available-swap-space-with-a-swap-file
and also runned:
echo 1 > /proc/sys/vm/overcommit_memory
cheers!
精彩评论