import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class Application {
    private static final Logger logger = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {
        logger.info("Starting worker...");

        try {
            Worker worker = new Worker();
            worker.connectToZookeeper();
            worker.work();
        } catch (IOException | KeeperException | InterruptedException e) {
            logger.error("Worker failed due to Zookeeper exception", e);
        } catch (RuntimeException e) {
            logger.error("Worker crashed due to application error", e);
        }
    }
}
