package cn.base.debug;

import org.apache.log4j.Logger;

import cn.base.conf.ModuleConfFactory;

import com.jtiny.telnetserver.TelnetCommandExecutor;
import com.jtiny.telnetserver.TelnetServerApp;

public class DebugCmdService {
	static Logger logger = Logger.getLogger(DebugCmdService.class);
	public static TelnetServerApp         debugApp=null;
	public int start(){
		int debugPort= ModuleConfFactory.getInstance().getScatter().getDebugPort();
		debugApp=new TelnetServerApp("127.0.0.1",debugPort,"pac:>");
		if(debugApp.getSocketTask().doInitListen()==false)
		{
			logger.info("***********Start debug task error! Please check debugPort. config port is "+debugPort);
			return -1;
		}
		debugApp.startTelnetServer();
		logger.info("***************Start debug thread success... ...");
		DebugCmdShow debugCmdShow=new DebugCmdShow();
		TelnetCommandExecutor.getInstance().registerCommand(debugCmdShow);
		DebugCmdHelp debugCmdHelp=new DebugCmdHelp(); 
		TelnetCommandExecutor.getInstance().registerCommand(debugCmdHelp);
		return 0;
	}
}
