jekylllivereloadwebrick

Why is Jekyll not working with live reload option?


Jekyll had been working fine for me about 50 times live-reloading.

However, now, each time I want to use live-reload option it throws this error once and once again, many times:

$ jekyll serve -l
Configuration file: MY_SITE/_config.yml
            Source: MY_SITE
       Destination: MY_SITE/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
                    done in 0.473 seconds.
 Auto-regeneration: enabled for '.../docs'
LiveReload address: http://127.0.0.1:35729
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.
        LiveReload: Browser connected
      Regenerating: 1 file(s) changed at 2024-02-13 09:26:26
                    CHANGED_FILE_PATH
       Jekyll Feed: Generating feed for posts
                    ...done in 0.235080909 second
[2024-02-13 09:26:26] ERROR Errno::ECONNRESET: Connection reset by peer @ io_fillbuf - fd:30 
    HOME/.rvm/gems/ruby-3.1.2/gems/webrick-1.8.1/lib/webrick/httpserver.rb:82:in `eof?'
    HOME/.rvm/gems/ruby-3.1.2/gems/webrick-1.8.1/lib/webrick/httpserver.rb:82:in `run'
    HOME/.rvm/gems/ruby-3.1.2/gems/webrick-1.8.1/lib/webrick/server.rb:310:in `block in start_thread'

And it does not regenerate anything.


Solution

  • I solved it using docker!

    # docs/Dockerfile
    
    FROM ruby:3.3 as base
    
    RUN apt-get update -qq && apt-get install -y build-essential apt-utils libpq-dev # nodejs
    
    COPY . /docker/app/
    
    WORKDIR /docker/app/docs
    
    RUN gem install bundler
    
    CMD bundle install && jekyll serve
    
    # docker-compose.yml
    version: '3.8'
    services:
      jekyll:
        build:
          context: .
          dockerfile: docs/Dockerfile
        volumes:
          - .:/docker/app
        ports:
          - "4000:4000"
          - "35729:35729"
    
    # docs/_config.yml
    host: 0.0.0.0