embedded-redis icon indicating copy to clipboard operation
embedded-redis copied to clipboard

start redis server on own executable fail

Open zhouhoo opened this issue 8 years ago • 6 comments

When use fellow way to create a redis server based on own executable, it fail . String redisPath ="/usr/local/bin/redis-server"; File file = new File(redisPath); RedisServer redisServer = new RedisServer(file, 6379); with error as fellow: Exception in thread "main" redis.embedded.exceptions.EmbeddedRedisException: Failed to start Redis instance at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:42) at redis.embedded.RedisServer.start(RedisServer.java:9) at com.blue.util.VoiceRecognation.start_s(VoiceRecognation.java:44) at com.blue.util.VoiceRecognation.main(VoiceRecognation.java:167) Caused by: java.io.IOException: Cannot run program "/usr/local/bin/redis-server " (in directory "/usr/local/bin"): error=2,no such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047) at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:37) ... 3 more Caused by: java.io.IOException: error=2, no such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:187) at java.lang.ProcessImpl.start(ProcessImpl.java:130) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028) ... 4 more but the file is truly there and with 755 .
my own redis executable version is 3.2 , ubuntu14.04. so this is a bug?

zhouhoo avatar May 22 '17 08:05 zhouhoo

It looks like there is an extra trailing space in the name of the executable that ProcessBuilder is attempting to start: "/usr/local/bin/redis-server ". Is there a typo in your assignment to String redisPath? Or maybe something is modifying it before it's passed to new ProcessBuilder(args);?

tklovett avatar May 23 '17 15:05 tklovett

For anyone else with my issue: I got this same error attempting to run my application within Alpine Linux -- the embedded redis-server-2.8.19 OsArchitecture.UNIX_x86_64 executable is successfully extracted from the Jar to /tmp/*, but Alpine is unable to execute it.

tklovett avatar May 23 '17 15:05 tklovett

@tklovett I faced with this problem too and I suggest that I have found a reason of the error. The problem in Alpine distribution, the os does't work with the format of program. It needs recompilation of redis, which contains in jar. So, if you want read about it more , you can go to https://github.com/awslabs/amazon-kinesis-producer/issues/86

izebit avatar Aug 02 '17 14:08 izebit

As similar to the situation above, I encountered the problem with running the embedded redis server in a Docker container. The image was originated from java:8-jre-alpine. It works after changing the base image to: openjdk:8-jre. But, the built docker image becomes larger though :)

mengjiann avatar Oct 09 '18 06:10 mengjiann

Any way to fix this other than changing the base image please?

IEnoobong avatar May 14 '22 09:05 IEnoobong

As similar to the situation above, I encountered the problem with running the embedded redis server in a Docker container. The image was originated from java:8-jre-alpine. It works after changing the base image to: openjdk:8-jre. But, the built docker image becomes larger though :)

yeah! I change maven:3.9.6-eclipse-temurin-11-alpine to maven:3.9.6-eclipse-temurin-11 and it works.

ycyin avatar Feb 21 '24 01:02 ycyin