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 with exception", e);
            System.exit(1);
        } catch (RuntimeException e) {
            logger.error("Critical failure, shutting down worker", e);
            System.exit(1);
        }
    }
}
