Skip to content
Snippets Groups Projects
etc_init_d_elastalert 770 B
Newer Older
  • Learn to ignore specific revisions
  • #!/bin/sh
    
    ### BEGIN INIT INFO
    # Provides: elastalert
    # Short-Description: Start and stop ElastAlert
    # Description: ElastAlert
    # Required-Start: $remote_fs
    # Required-Stop: $remote_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    ### END INIT INFO
    
    export HOME=/root
    
    # Action to take
    case "$1" in
        start)
            echo "Starting ElastAlert ..."
            cd /opt/elastalert
            /usr/local/bin/elastalert &
            exit 0
            ;;
        stop)
            echo "Stoping ElastAlert ..."
            kill `pidof /usr/bin/python /usr/local/bin/elastalert` && echo "ElastAlert stopped"
            exit 0
            ;;
        restart)
            $0 stop
            $0 start
            ;;
        *)
            echo "Usage: service elastalert {start|stop|restart}"
            exit 1
            ;;
    esac
    
    exit $?