1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00

#171 fix docker container startup error

This commit is contained in:
Hai Liang Wang 2018-12-11 15:19:59 +08:00
parent 99e9272f17
commit 49cf897589
3 changed files with 23 additions and 21 deletions

View File

@ -1,4 +1,4 @@
FROM tomcat:8.5.35-slim
FROM chatopera/java:1.0.0
MAINTAINER Hai Liang Wang <hain@chatopera.com>
ARG VCS_REF
@ -20,12 +20,20 @@ ENV LANG C.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL C.UTF-8
# set ENVs
ENV JAVA_HOME=/opt/java-8-oracle
ENV TOMCAT_HOME=/opt/apache-tomcat
ENV PATH=$PATH:$JAVA_HOME/bin
# create dirs
RUN /bin/bash -c "mkdir -p /{data,logs}"
# copy WAR
RUN rm -rf /usr/local/tomcat/webapps/*
COPY ./app/target/contact-center-3.9.0.war.original /usr/local/tomcat/webapps/ROOT.war
COPY ./config/tomcat.context.xml /usr/local/tomcat/conf/context.xml
# build WAR
RUN rm -rf /opt/apache-tomcat/webapps/ROOT*
COPY ./app/target/contact-center-*.war.original /opt/apache-tomcat/webapps/ROOT.war
EXPOSE 8030-8090 9200 9300
# clean files
RUN rm -rf /root/.m2
EXPOSE 8030-8090 9200 9300
CMD ["/opt/apache-tomcat/bin/catalina.sh", "run"]

View File

@ -16,13 +16,13 @@
package com.chatopera.cc.app.handler.api.rest;
import com.chatopera.bot.exception.ChatbotException;
import com.chatopera.cc.app.basic.MainContext;
import com.chatopera.cc.app.basic.MainUtils;
import com.chatopera.cc.app.handler.Handler;
import com.chatopera.cc.app.handler.api.request.RestUtils;
import com.chatopera.cc.app.im.util.ChatbotUtils;
import com.chatopera.cc.app.model.*;
import com.chatopera.cc.app.persistence.repository.*;
import com.chatopera.cc.concurrent.chatbot.ChatbotEventHandler;
import com.chatopera.cc.exception.CallOutRecordException;
import com.chatopera.cc.util.Menu;
import com.chatopera.cc.util.OnlineUserUtils;
@ -185,7 +185,7 @@ public class ApiChatbotController extends Handler {
}
try {
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(c.getClientId(), c.getSecret());
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(c.getClientId(), c.getSecret(), ChatbotEventHandler.getChatbotServiceUrl());
if (bot.exists()) {
c.setEnabled(isEnabled);
chatbotRes.save(c);
@ -206,6 +206,7 @@ public class ApiChatbotController extends Handler {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_6);
resp.addProperty(RestUtils.RESP_KEY_DATA, "设置不成功,智能问答引擎地址不合法。");
} catch (ChatbotException e) {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5);
resp.addProperty(RestUtils.RESP_KEY_DATA, "设置不成功,智能问答引擎服务异常。");
}
@ -267,7 +268,7 @@ public class ApiChatbotController extends Handler {
}
try {
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(c.getClientId(), c.getSecret());
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(c.getClientId(), c.getSecret(), ChatbotEventHandler.getChatbotServiceUrl());
if (bot.exists()) {
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
resp.addProperty(RestUtils.RESP_KEY_DATA, "更新成功。");
@ -484,7 +485,8 @@ public class ApiChatbotController extends Handler {
}
try {
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(clientId, secret, getBotBaseUrl());
logger.info("create bot with url {}", ChatbotEventHandler.getChatbotServiceUrl());
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(clientId, secret, ChatbotEventHandler.getChatbotServiceUrl());
if (bot.exists()) { // 该机器人存在clientId Secret配对成功
// 创建成功
@ -493,7 +495,7 @@ public class ApiChatbotController extends Handler {
c.setId(MainUtils.getUUID());
c.setClientId(clientId);
c.setSecret(secret);
c.setBaseUrl(getBotBaseUrl());
c.setBaseUrl(ChatbotEventHandler.getChatbotServiceUrl());
c.setDescription(botDetails.getJSONObject("data").getString("description"));
c.setFallback(botDetails.getJSONObject("data").getString("fallback"));
c.setPrimaryLanguage(botDetails.getJSONObject("data").getString("primaryLanguage"));
@ -547,11 +549,4 @@ public class ApiChatbotController extends Handler {
return resp;
}
}
private String getBotBaseUrl(){
if(this.botBaseUrl == null)
this.botBaseUrl = MainContext.getContext().getEnvironment().getProperty("chatopera.bot.url");
return this.botBaseUrl;
}
}

View File

@ -40,7 +40,7 @@ public class ChatbotEventHandler implements EventHandler<UserDataEvent> {
private ChatbotRepository chatbotRes;
private AgentUserRepository agentUserRes;
private String botServiceUrl;
private static String botServiceUrl;
/**
* 根据聊天机器人返回数据更新agentUser
@ -140,11 +140,10 @@ public class ChatbotEventHandler implements EventHandler<UserDataEvent> {
}
private String getChatbotServiceUrl() {
public static String getChatbotServiceUrl() {
if (botServiceUrl == null) {
botServiceUrl = MainContext.getContext().getEnvironment().getProperty("chatopera.bot.url");
}
return botServiceUrl;
}
}