package com.muyu.cargateway.instance;

import com.muyu.cargateway.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;

/**
 * @ Tool：IntelliJ IDEA
 * @ Author：CHX
 * @ Date：2024-10-07-21:51
 * @ Version：1.0
 * @ Description：删除实例方法
 * @author Lenovo
 */
@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("删除实例成功");
    }
}
