A-A+
supervisor守护scala应用故障处理
在部署scala应用时,使用supervisor做进程守护时提示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
Oops, cannot start the server. java.nio.charset.MalformedInputException: Input length = 1 at java.nio.charset.CoderResult.throwException(CoderResult.java:281) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) at java.io.InputStreamReader.read(InputStreamReader.java:184) at java.io.BufferedReader.fill(BufferedReader.java:161) at java.io.BufferedReader.readLine(BufferedReader.java:324) at java.io.BufferedReader.readLine(BufferedReader.java:389) at scala.io.BufferedSource$BufferedLineIterator.hasNext(BufferedSource.scala:70) at scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:447) at scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:447) at scala.collection.Iterator.foreach(Iterator.scala:929) at scala.collection.Iterator.foreach$(Iterator.scala:929) at scala.collection.AbstractIterator.foreach(Iterator.scala:1417) at scala.collection.TraversableOnce.toMap(TraversableOnce.scala:316) at scala.collection.TraversableOnce.toMap$(TraversableOnce.scala:314) at scala.collection.AbstractIterator.toMap(Iterator.scala:1417) at tools.CityMapping$.init(CityMapping.scala:24) at AppComponents.<init>(AppComponents.scala:116) at AppLoader.load(AppLoader.scala:18) at play.core.server.ProdServerStart$.start(ProdServerStart.scala:47) at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22) at play.core.server.ProdServerStart.main(ProdServerStart.scala) |
手动切换到这个目录执行的时候却可以正常启动。
分析原因得知要加载一个city.txt的文件,google很多都提示是编码问题,于是让RD在代码里指定编码,修改提交部署后还是不行。
最后我在supervisord.conf中command里指定编码(-Dfile.encoding=UTF-8),启动成功。具体代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
[program:transform] command=/root/app/transform-1.0.0-8000/bin/transform -J-Xms4g -J-Xmx4g -J-XX:+HeapDumpOnOutOfMemoryError -J-server -Dhttp.port=8000 -Dconfig.resource=application-prd.conf -Dlogger.resource=logback-prd.xml -Dfile.encoding=UTF-8 directory=/root/app/transform-1.0.0-8000/ process_name=%(program_name)s umask=022 priority=100 autostart=true autorestart=true startsecs=10 startretries=3 stopsignal=TERM stopwaitsecs=10 stopasgroup=false killasgroup=false user=root redirect_stderr=false stdout_logfile=NONE stdout_logfile_maxbytes=100MB stdout_logfile_backups=10 stdout_events_enabled=false stderr_logfile=/mnt/data/logs/transform/error.log stderr_logfile_maxbytes=100MB stderr_logfile_backups=10 stderr_events_enabled=false |