package com.muyu.cloud.vehicle.gateway.aliyun.ecs;

import com.muyu.cloud.vehicle.gateway.aliyun.service.AliYunEcsService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *删除实例方法
 */
@Log4j2
@Component
public class DeleteSample implements DisposableBean {

    @Autowired
    private AliYunEcsService aliYunEcsService;
    @Override
    public void destroy() {
        try{
            log.info("==========开始执行删除实例方法");
            Thread.sleep(10000);
            aliYunEcsService.deleteInstance();
        } catch (Exception e) {
            log.info("删除实例失败");
            throw new RuntimeException(e);
        }
        log.info("删除实例成功");
    }
}
