runStartingFromList :: FilePath -> IO ()
runStartingFromList filePath = do
    handle <- openFile filePath ReadMode
    handle2 <- openFile filePath ReadMode
    (store,nextPage) <- buildNextPage
    items_counter <- createCounter "items_counter" store
    r <- runEffect $ P.length (P.fromHandle handle)
    let itemsPerSegment = r `div` maxThreads
    print itemsPerSegment
    dividers <-
        evalStateT
            (P.toListM $ (P.fromHandle handle2) >->
             P.filterM (takeEveryNth itemsPerSegment))
            itemsPerSegment
    let dividers' = fmap (T.pack) dividers
    let startSegments = (Just "logs/2016-01-01") : (fmap Just dividers')
    let endSegments = fmap Just dividers' ++ [Just "m"]
    let segments = zip startSegments endSegments
    print segments
    print $ length segments
    threads <-
        forM
            segments
            (\s ->
                  forkThread (downloadSegment items_counter nextPage s))
    mapM_ takeMVar threads
runStartingFromList :: FilePath -> IO ()
runStartingFromList filePath = do
    handle <- openFile filePath ReadMode
    handle2 <- openFile filePath ReadMode
    (store,nextPage) <- buildNextPage
    items_counter <- createCounter "items_counter" store
    r <- runEffect $ P.length (P.fromHandle handle)
    let itemsPerSegment = r `div` maxThreads
    print itemsPerSegment
    dividers <-
        evalStateT
            (P.toListM $ (P.fromHandle handle2) >->
             P.filterM (takeEveryNth itemsPerSegment))
            itemsPerSegment
    let dividers' = fmap (T.pack) dividers
    let startSegments = (Just "logs/2016-01-01") : (fmap Just dividers')
    let endSegments = fmap Just dividers' ++ [Just "m"]
    let segments = zip startSegments endSegments
    print segments
    print $ length segments
    threads <-
        forM
            segments
            (\s ->
                  forkThread (downloadSegment items_counter nextPage s))
    mapM_ takeMVar threads
runStartingFromList filePath = do
    handle <- openFile filePath ReadMode
    handle2 <- openFile filePath ReadMode
    (store,nextPage) <- buildNextPage
    items_counter <- createCounter "items_counter" store
    r <- runEffect $ P.length (P.fromHandle handle)
    let itemsPerSegment = r `div` maxThreads
    print itemsPerSegment
    dividers <-
        evalStateT
            (P.toListM $ (P.fromHandle handle2) >->
             P.filterM (takeEveryNth itemsPerSegment))
            itemsPerSegment
    let dividers' = fmap (T.pack) dividers
    let startSegments = (Just "logs/2016-01-01") : (fmap Just dividers')
    let endSegments = fmap Just dividers' ++ [Just "m"]
    let segments = zip startSegments endSegments
    print segments
    print $ length segments
    threads <-
        forM
            segments
            (\s ->
                  forkThread (downloadSegment items_counter nextPage s))
    mapM_ takeMVar threads