001package net.gdface.service.sdk; 002 003import java.io.BufferedReader; 004import java.io.IOException; 005import java.io.InputStreamReader; 006 007import org.jboss.netty.logging.InternalLoggerFactory; 008import org.jboss.netty.logging.Slf4JLoggerFactory; 009 010/** 011 * 启动 FaceApi thrift 服务 012 * @author guyadong 013 * 014 */ 015public class FaceApiServiceMain implements FaceApiServiceConstants{ 016 private static final FaceApiServiceConfig serviceConfig = FaceApiServiceConfig.getInstance(); 017 018 public FaceApiServiceMain() { 019 } 020 private static void waitquit(){ 021 System.out.println("PRESS 'quit' OR 'CTRL-C' to exit"); 022 BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); 023 try{ 024 while(!"quit".equalsIgnoreCase(reader.readLine())){ 025 } 026 System.exit(0); 027 } catch (IOException e) { 028 029 }finally { 030 031 } 032 } 033 public static void main(String ...args){ 034 Logo.textLogo(); 035 serviceConfig.parseCommandLine(args); 036 // 设置slf4j记录日志,否则会有警告 037 InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory()); 038 FaceApiService.buildService().startAsync(); 039 if(serviceConfig.isXhrStart()){ 040 FaceApiService.buildHttpService().startAsync(); 041 } 042 if(serviceConfig.isRestfulStart()){ 043 FaceApiService.startRestfulService(); 044 } 045 waitquit(); 046 } 047 048}