public static void main(String[] args)
throws ClassNotFoundException
{
logger.info("Agent 正在启动");
logger.info("设置文件锁,保证单实例");
FileLock flock = null;
try
{
flock = new FileOutputStream("/opt/usp/agent/agent.lock").getChannel().tryLock();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e1)
{
e1.printStackTrace();
}
if (flock == null)
{
logger.info("Agent 已经运行,启动失败....");
System.exit(1);
}
时间: 2024-11-04 19:29:31