LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.28k stars 884 forks source link

Lemmy doesnt start because of missing config fields #1550

Closed the-digital-anarchist closed 3 years ago

the-digital-anarchist commented 3 years ago

Just pulled in 0.10 lemmy-ui and lemmy. Locally everything works fine. But when I deploy it with ansible I get this error: FetchError: request to http://lemmy:8536/api/v3/site? failed, reason: getaddrinfo ENOTFOUND lemmy

This request gets made in the server/index.js file here

 // Get site data first
let site = await initialFetchReq.client.getSite(getSiteForm);

But it looks like the jwt token doesn't get generated because normally it's 'http://lemmy:8536/api/v3/site?'

Here are my settings:

lemmy/ansible/templates/docker-compose.yml

version: '2.2'

services:
  lemmy:
    image: dessalines/lemmy:0.10.2
    ports:
      - "127.0.0.1:8536:8536"
    restart: always
    environment:
      - RUST_LOG=error
    volumes:
      - ./lemmy.hjson:/config/config.hjson:ro
    depends_on:
      - postgres
      - pictrs
      - iframely

  lemmy-ui:
    image: dessalines/lemmy-ui:0.10.0
    ports:
      - "127.0.0.1:1235:1234"
    restart: always
    environment:
      - LEMMY_INTERNAL_HOST=lemmy:8536
      - LEMMY_EXTERNAL_HOST={{ domain }}
      - LEMMY_HTTPS=true

    depends_on:
      - lemmy

  postgres:
    image: postgres:12-alpine
    environment:
      - POSTGRES_USER=****
      - POSTGRES_PASSWORD={{ postgres_password }}
      - POSTGRES_DB=****
    volumes:
      - ./volumes/postgres:/var/lib/postgresql/data
    restart: always

  pictrs:
    image: asonix/pictrs:v0.2.6-r1
    user: 991:991
    ports:
      - "127.0.0.1:8537:8080"
    volumes:
      - ./volumes/pictrs:/mnt
    restart: always
    mem_limit: 200m

  iframely:
    image: dogbin/iframely:latest
    ports:
      - "127.0.0.1:8061:80"
    volumes:
      - ./iframely.config.local.js:/iframely/config.local.js:ro
    restart: always
    mem_limit: 200m

  postfix:
    image: mwader/postfix-relay
    environment:
      - POSTFIX_myhostname={{ domain }}
    restart: "always"

lemmy/ansible/templates/config.hjson

{
  # for more info about the config, check out the documentation
  # https://join.lemmy.ml/docs/en/administration/configuration.html

  # settings related to the postgresql database
  database: {
    database: lemmy
    user: ****
    host: postgres
    port: ****
    pool_size: 5
    # password to connect to postgres
    password: "{{ postgres_password }}"
  }
  # the domain name of your instance (eg "lemmy.ml")
  hostname: "{{ domain }}"
  # the port where lemmy should listen for incoming requests
  port: 8536
  # json web token for authorization between server and client
  jwt_secret: "{{ jwt_password }}"
  # address where lemmy should listen for incoming requests
  bind: "0.0.0.0"
  # whether tls is required for activitypub. only disable this for debugging, never for producion.
  tls_enabled: true
  # email sending configuration
  email: {
    # hostname of the smtp server
    smtp_server: "postfix:25"
    # address to send emails from, eg "noreply@your-instance.com"
    smtp_from_address: "noreply@{{ domain }}"
    use_tls: false
  }
  rate_limit: {
    # maximum number of messages created in interval
    message: 180
    # interval length for message limit
    message_per_second: 40
    # maximum number of posts created in interval
    post: 10
    # interval length for post limit
    post_per_second: 20
    # maximum number of registrations in interval
    register: 3
    # interval length for registration limit
    register_per_second: 3600
    # maximum number of image uploads in interval
    image: 10
    # interval length for image uploads
    image_per_second: 2400
  }
  # settings related to activitypub federation
  federation: {
    # whether to enable activitypub federation. 
    enabled: false
    # Allows and blocks are described here:
    # https://join.lemmy.ml/docs/en/federation/administration.html#instance-allowlist-and-blocklist
    #
    # comma separated list of instances with which federation is allowed
    # Only one of these blocks should be uncommented
    # allowed_instances: ["instance1.tld","instance2.tld"]
    # comma separated list of instances which are blocked from federating
    # blocked_instances: []
  }
}

All the passwords vars work so that's not the problem. But further I've got no idea what it could be.

dessalines commented 3 years ago

Those files aren't too helpful, because those aren't the versions on your server, those are the versions from your local ansible folder.

FetchError: request to http://lemmy:8536/api/v3/site? failed, reason: getaddrinfo ENOTFOUND lemmy

That doesn't help me too much, because that's a lemmy-ui error, when the problem is likely on the back end.

There's some weird conflicting things going on with your docker-compose.

The current one uses :

lemmy-ui:
    image: dessalines/lemmy-ui:0.10.2

- LEMMY_INTERNAL_HOST=lemmy:8536 seems correct, so I'm not sure why node isn't finding that address.

run

sudo docker-compose up -d
sudo docker-compose logs lemmy
the-digital-anarchist commented 3 years ago

@dessalines I've set lemmy-ui version to 0.10.2 to reflect the lemmy:0.10.2 After that I did a new deploy, and run:

sudo docker-compose up -d

Output:
lemmy_postfix_1 is up-to-date
lemmy_iframely_1 is up-to-date
lemmy_postgres_1 is up-to-date
lemmy_pictrs_1 is up-to-date
lemmy_lemmy_1 is up-to-date
lemmy_lemmy-ui_1 is up-to-date
sudo docker-compose logs lemmy

Output:
lemmy_1     | thread 'main' panicked at 'Failed to load settings file: LemmyError { inner: "missing field `user`" near 11:3 }', crates/utils/src/settings/mod.rs:26:34
lemmy_1     | note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
lemmy_1     | Panic in Arbiter thread.

These are my server config files: docker-compose.yml

version: '2.2'

services:
  lemmy:
    image: dessalines/lemmy:0.10.2
    ports:
      - "127.0.0.1:8536:8536"
    restart: always
    environment:
      - RUST_LOG=error
    volumes:
      - ./lemmy.hjson:/config/config.hjson:ro
    depends_on:
      - postgres
      - pictrs
      - iframely

  lemmy-ui:
    image: dessalines/lemmy-ui:0.10.2
    ports:
      - "127.0.0.1:1235:1234"
    restart: always
    environment:
      - LEMMY_INTERNAL_HOST=lemmy:8536
      - LEMMY_EXTERNAL_HOST=***
      - LEMMY_HTTPS=true
    depends_on:
      - lemmy

  postgres:
    image: postgres:12-alpine
    environment:
      - POSTGRES_USER=***
      - POSTGRES_PASSWORD=****
      - POSTGRES_DB=lemmy
    volumes:
      - ./volumes/postgres:/var/lib/postgresql/data
    restart: always

  pictrs:
    image: asonix/pictrs:v0.2.6-r1
    user: 991:991
    ports:
      - "127.0.0.1:8537:8080"
    volumes:
      - ./volumes/pictrs:/mnt
    restart: always
    mem_limit: 200m

  iframely:
    image: dogbin/iframely:latest
    ports:
      - "127.0.0.1:8061:80"
    volumes:
      - ./iframely.config.local.js:/iframely/config.local.js:ro
    restart: always
    mem_limit: 200m

  postfix:
    image: mwader/postfix-relay
    environment:
      - POSTFIX_myhostname=***
    restart: "always"

lemmy.hjson

{
  # for more info about the config, check out the documentation
  # https://dev.lemmy.ml/docs/administration_configuration.html

  # settings related to the postgresql database
  database: {
    # password to connect to postgres
    password: "***"
    # host where postgres is running
    host: "postgres"
  }
  # the domain name of your instance (eg "dev.lemmy.ml")
  hostname: "forum.forumvooranarchisme.nl"
  # address where lemmy should listen for incoming requests
  bind: "0.0.0.0"
  # json web token for authorization between server and client
  jwt_secret: "***"
  # email sending configuration
  email: {
    # hostname of the smtp server
    # smtp_server: "postfix:25"
    # address to send emails from, eg "noreply@your-instance.com"
    smtp_from_address: "noreply@***"
    use_tls: true
    # hostname and port of the smtp server
    smtp_server: "smtp.transip.email:465"
    # login name for smtp server
    smtp_login: "noreply@***"
    # password to login to the smtp server
    smtp_password: "***"
  }
  # settings related to activitypub federation
  federation: {
    # whether to enable activitypub federation.
    enabled: false
    # Allows and blocks are described here:
    # https://dev.lemmy.ml/docs/administration_federation.html#instance-allowlist-and-blocklist
    #
    # comma separated list of instances with which federation is allowed
    # allowed_instances: ""
    # comma separated list of instances which are blocked from federating
    # blocked_instances: ""
  }
}
Nutomic commented 3 years ago

The database section needs to look like this:


  # settings related to the postgresql database
  database: {
    database: lemmy
    user: lemmy
    host: postgres
    # password to connect to postgres
    password: "***"
    # host where postgres is running
    port: 5432
    pool_size: 5
  }

So we need to add those values to the default config, or make them optional like they were before.

the-digital-anarchist commented 3 years ago

Oke awesome! That was the problem. I'm closing it.

Nutomic commented 3 years ago

Keeping this open until we release a fix.

pullopen commented 3 years ago

Strangely, my site works well on v0.9.9, but while I try to upgrade it to v0.10.3, it can not start up and shows this error:

thread 'main' panicked at 'Failed to load settings file: LemmyError { inner: ExpectedArray at 77:25 at "\"\n    # comma s" }', crates/utils/src/settings/mod.rs:29:34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Panic in Arbiter thread.

I wonder why?

dessalines commented 3 years ago

Open up a new issue and post your hjson config.