standardnotes / self-hosted

[Legacy] Self-host your own Standard Notes server for end-to-end encrypted notes and files
https://github.com/standardnotes/server
GNU Affero General Public License v3.0
343 stars 39 forks source link

[BUG] Cannot start workspace-standalone and files-standalone #87

Open Bizzaro opened 1 year ago

Bizzaro commented 1 year ago

Service Versions (please complete the following information): Paste the output of ./server.sh version. For example:

             Container                          Repository                 Tag         Image Id       Size  
------------------------------------------------------------------------------------------------------------
api-gateway-standalone                standardnotes/api-gateway         latest       57641ced0fff   148.7 MB
auth-standalone                       standardnotes/auth                latest       3e816890684f   174.1 MB
auth-worker-standalone                standardnotes/auth                latest       3e816890684f   174.1 MB
cache-standalone                      redis                             6.0-alpine   83c577984741   24.65 MB
db-standalone                         mysql                             5.6          dd3b2a5dcb48   302.5 MB
files-standalone                      standardnotes/files               latest       41189afc5603   150.3 MB
syncing-server-js-standalone          standardnotes/syncing-server-js   latest       824706101f0b   171.7 MB
syncing-server-js-worker-standalone   standardnotes/syncing-server-js   latest       824706101f0b   171.7 MB
workspace-standalone                  standardnotes/workspace           latest       e1c7a4c5593e   159.4 MB
workspace-worker-standalone           standardnotes/workspace           latest       e1c7a4c5593e   159.4 MB

Describe the bug A clear and concise description of what the bug is. Unable to start the server, the script fails to start files-standalone and workplace-standalone

To Reproduce Steps to reproduce the behavior:

  1. Run sudo ./server.sh start

Expected behavior The server to start

Logs If applicable, add logs to help debug your problem.

files-standalone            | cache:6379 is up - executing command
files-standalone            | Starting Web...
files-standalone            | Internal Error: Error when performing the request
files-standalone            |     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:3937:20)
files-standalone            |     at ClientRequest.emit (node:events:527:28)
files-standalone            |     at TLSSocket.socketErrorListener (node:_http_client:454:9)
files-standalone            |     at TLSSocket.emit (node:events:527:28)
files-standalone            |     at emitErrorNT (node:internal/streams/destroy:157:8)
files-standalone            |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
files-standalone            |     at processTicksAndRejections (node:internal/process/task_queues:83:21)
files-standalone            | db (172.21.0.2:3307) open
files-standalone            | db:3307 is up - executing command
files-standalone            | cache (172.21.0.4:6379) open
files-standalone            | cache:6379 is up - executing command
files-standalone            | Starting Web...
files-standalone            | Internal Error: Error when performing the request
files-standalone            |     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:3937:20)
files-standalone            |     at ClientRequest.emit (node:events:527:28)
files-standalone            |     at TLSSocket.socketErrorListener (node:_http_client:454:9)
files-standalone            |     at TLSSocket.emit (node:events:527:28)
files-standalone            |     at emitErrorNT (node:internal/streams/destroy:157:8)
files-standalone            |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
files-standalone            |     at processTicksAndRejections (node:internal/process/task_queues:83:21)
db (172.21.0.4:3307) open
db:3307 is up - executing command
cache (172.21.0.3:6379) open
cache:6379 is up - executing command
Starting Web...
Internal Error: Error when performing the request
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:3937:20)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
workspace-worker-standalone | workspace:3000 is unavailable yet - waiting for it to start
workspace-standalone        | Internal Error: Error when performing the request
workspace-standalone        |     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:3937:20)
workspace-standalone        |     at ClientRequest.emit (node:events:527:28)
workspace-standalone        |     at TLSSocket.socketErrorListener (node:_http_client:454:9)
workspace-standalone        |     at TLSSocket.emit (node:events:527:28)
workspace-standalone        |     at emitErrorNT (node:internal/streams/destroy:157:8)
workspace-standalone        |     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
workspace-standalone        |     at processTicksAndRejections (node:internal/process/task_queues:83:21)
db (172.21.0.4:3307) open
db:3307 is up - executing command
cache (172.21.0.3:6379) open
cache:6379 is up - executing command
Starting Web...
auth (172.21.0.6:3000) open
auth:3000 is up - executing command
Internal Error: Error when performing the request
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:3937:20)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
db (172.21.0.4:3307) open
db:3307 is up - executing command
cache (172.21.0.3:6379) open
cache:6379 is up - executing command
Starting Web...
auth (172.21.0.6:3000) open
auth:3000 is up - executing command
Internal Error: Error when performing the request
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:3937:20)
    at ClientRequest.emit (node:events:527:28)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Additional context I upgraded, resolved some merge conflicts and here we are. workspace-standalone and files-standalone keep crashing with a generic error message, even with the log level set to debug in the config files.

auth.env

LOG_LEVEL="info"
NODE_ENV="production"
VERSION="local"

AUTH_JWT_TTL=60000
JWT_SECRET=XXXXXXXXXXXXXXXXXX
LEGACY_JWT_SECRET=XXXXXXXXXXXXXXXXXx

NEW_RELIC_ENABLED=false
NEW_RELIC_APP_NAME=Auth
NEW_RELIC_NO_CONFIG_FILE=true

REDIS_EVENTS_CHANNEL="auth-events"

DISABLE_USER_REGISTRATION=false

PSEUDO_KEY_PARAMS_KEY=secret_key

ACCESS_TOKEN_AGE=5184000
REFRESH_TOKEN_AGE=31556926

MAX_LOGIN_ATTEMPTS=6
FAILED_LOGIN_LOCKOUT=3600

EPHEMERAL_SESSION_AGE=259200

# Must be a hex string exactly 32 bytes long
# e.g. feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308
ENCRYPTION_SERVER_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

SYNCING_SERVER_URL=http://syncing-server-js:4321

# File Uploads
VALET_TOKEN_TTL=7200

api-gateway.env

LOG_LEVEL="info"
NODE_ENV="production"
VERSION="local"

NEW_RELIC_ENABLED=false
NEW_RELIC_APP_NAME="API Gateway"
NEW_RELIC_NO_CONFIG_FILE=true

SYNCING_SERVER_JS_URL="http://syncing-server-js:3000"
AUTH_SERVER_URL="http://auth:3000"

REDIS_EVENTS_CHANNEL="api-gateway-events"

WORKSPACE_SERVER_URL=http://workspace:3000

files.env

LOG_LEVEL=debug
NODE_ENV=production
VERSION=local

PORT=3000

S3_BUCKET_NAME=
S3_AWS_REGION=
SNS_TOPIC_ARN=
SNS_AWS_REGION=

REDIS_URL=redis://cache
REDIS_EVENTS_CHANNEL=events

MAX_CHUNK_BYTES=100000000

NEW_RELIC_ENABLED=false

workspace.env

LOG_LEVEL=debug
NODE_ENV=production
VERSION=local

PORT=3000

REDIS_URL=redis://cache
REDIS_EVENTS_CHANNEL="workspace-events"

NEW_RELIC_ENABLED=false

.env

LOG_LEVEL=info
NODE_ENV=development
VERSION=local

AUTH_JWT_SECRET=XXXXXXXXXXXXXXX

EXPOSED_PORT=4321

DB_HOST=db
DB_REPLICA_HOST=db
DB_PORT=3307
DB_USERNAME=XXXXXXXXXXXXXXXXX
DB_PASSWORD=XXXXXXXXXXXXXXXXXXXX
DB_DATABASE=standard_notes_db
DB_DEBUG_LEVEL=error # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
DB_MIGRATIONS_PATH=dist/migrations/*.js

REDIS_URL=redis://cache

SNS_TOPIC_ARN=
SNS_AWS_REGION=
SQS_QUEUE_URL=
SQS_AWS_REGION=
S3_AWS_REGION=
S3_BACKUP_BUCKET_NAME=

REDIS_EVENTS_CHANNEL=events

AUTH_SERVER_URL=http://auth:3000

EMAIL_ATTACHMENT_MAX_BYTE_SIZE=10485760

REVISIONS_FREQUENCY=300

# (Optional) New Relic Setup
NEW_RELIC_ENABLED=false
NEW_RELIC_APP_NAME="Syncing Server JS"
NEW_RELIC_LICENSE_KEY=
NEW_RELIC_NO_CONFIG_FILE=true
NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=false
NEW_RELIC_LOG_ENABLED=false
NEW_RELIC_LOG_LEVEL=info

# File upload path (relative to root directory)
FILE_UPLOAD_PATH=data/uploads

# File uploads
VALET_TOKEN_SECRET=XXXXXXXXXXXXX
EXPOSED_FILES_PORT=3125
# Public-facing URL of the Files server. Endpoint on which clients will access it.
FILES_SERVER_URL=http://localhost:3125

docker-compose.yml

version: '3.8'
services:
  syncing-server-js:
    image: standardnotes/syncing-server-js
    container_name: syncing-server-js-standalone
    depends_on:
      - db
      - cache
    entrypoint: [
      "./packages/syncing-server/wait-for.sh", "db", "3307",
      "./packages/syncing-server/wait-for.sh", "cache", "6379",
      "./packages/syncing-server/docker/entrypoint.sh", "start-web"
    ]
    env_file: .env
    environment:
      PORT: 3000
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  syncing-server-js-worker:
    image: standardnotes/syncing-server-js
    container_name: syncing-server-js-worker-standalone
    depends_on:
      - db
      - cache
      - syncing-server-js
    entrypoint: [
      "./packages/syncing-server/wait-for.sh", "db", "3307",
      "./packages/syncing-server/wait-for.sh", "cache", "6379",
      "./packages/syncing-server/wait-for.sh", "syncing-server-js", "3000",
      "./packages/syncing-server/docker/entrypoint.sh", "start-worker"
    ]
    env_file: .env
    environment:
      PORT: 3000
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  api-gateway:
    image: standardnotes/api-gateway
    container_name: api-gateway-standalone
    depends_on:
      - auth
      - syncing-server-js
    env_file: docker/api-gateway.env
    ports:
      - ${EXPOSED_PORT}:3000
    environment:
      PORT: 3000
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
      REDIS_URL: '${REDIS_URL}'
      FILES_SERVER_URL: '${FILES_SERVER_URL}'
    entrypoint: [
      "./packages/api-gateway/wait-for.sh", "auth", "3000",
      "./packages/api-gateway/wait-for.sh", "syncing-server-js", "3000",
      "./packages/api-gateway/wait-for.sh", "files", "3000",
      "./packages/api-gateway/docker/entrypoint.sh", "start-web"
    ]
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  auth:
    image: standardnotes/auth
    container_name: auth-standalone
    depends_on:
      - db
      - cache
      - syncing-server-js
    entrypoint: [
      "./packages/auth/wait-for.sh", "db", "3307",
      "./packages/auth/wait-for.sh", "cache", "6379",
      "./packages/auth/wait-for.sh", "syncing-server-js", "3000",
      "./packages/auth/docker/entrypoint.sh", "start-web"
    ]
    env_file: docker/auth.env
    environment:
      PORT: 3000
      DB_HOST: '${DB_HOST}'
      DB_REPLICA_HOST: '${DB_REPLICA_HOST}'
      DB_PORT: '${DB_PORT}'
      DB_DATABASE: '${DB_DATABASE}'
      DB_USERNAME: '${DB_USERNAME}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_DEBUG_LEVEL: '${DB_DEBUG_LEVEL}'
      DB_MIGRATIONS_PATH: '${DB_MIGRATIONS_PATH}'
      REDIS_URL: '${REDIS_URL}'
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
      VALET_TOKEN_SECRET: '${VALET_TOKEN_SECRET}'
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  auth-worker:
    image: standardnotes/auth
    container_name: auth-worker-standalone
    depends_on:
      - db
      - cache
      - auth
    entrypoint: [
      "./packages/auth/wait-for.sh", "db", "3307",
      "./packages/auth/wait-for.sh", "cache", "6379",
      "./packages/auth/wait-for.sh", "auth", "3000",
      "./packages/auth/docker/entrypoint.sh", "start-worker"
    ]
    env_file: docker/auth.env
    environment:
      PORT: 3000
      DB_HOST: '${DB_HOST}'
      DB_REPLICA_HOST: '${DB_REPLICA_HOST}'
      DB_PORT: '${DB_PORT}'
      DB_DATABASE: '${DB_DATABASE}'
      DB_USERNAME: '${DB_USERNAME}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_DEBUG_LEVEL: '${DB_DEBUG_LEVEL}'
      DB_MIGRATIONS_PATH: '${DB_MIGRATIONS_PATH}'
      REDIS_URL: '${REDIS_URL}'
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
      VALET_TOKEN_SECRET: '${VALET_TOKEN_SECRET}'
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  files:
    image: standardnotes/files
    container_name: files-standalone
    entrypoint: [
      "./packages/files/wait-for.sh", "db", "3307",
      "./packages/files/wait-for.sh", "cache", "6379",
      "./packages/files/docker/entrypoint.sh", "start-web"
    ]
    ports:
      - ${EXPOSED_FILES_PORT}:3000
    env_file: docker/files.env
    environment:
      FILE_UPLOAD_PATH: '${FILE_UPLOAD_PATH}'
      VALET_TOKEN_SECRET: '${VALET_TOKEN_SECRET}'
    volumes:
      - ./${FILE_UPLOAD_PATH}:/var/www/${FILE_UPLOAD_PATH}
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  db:
    image: mysql:5.6
    container_name: db-standalone
    environment:
      MYSQL_DATABASE: '${DB_DATABASE}'
      MYSQL_USER: '${DB_USERNAME}'
      MYSQL_PASSWORD: '${DB_PASSWORD}'
      MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
      MYSQL_TCP_PORT: 3307
    expose:
      - 3307
    restart: unless-stopped
    command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_general_ci
    volumes:
      - ./data/mysql:/var/lib/mysql
      - ./data/import:/docker-entrypoint-initdb.d
    networks:
      - standardnotes_standalone

  cache:
    image: redis:6.0-alpine
    container_name: cache-standalone
    volumes:
      - ./data/redis/:/data
    expose:
      - 6379
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  workspace:
    image: standardnotes/workspace
    container_name: workspace-standalone
    depends_on:
      - db
      - cache
      - auth
    entrypoint: [
      "./packages/workspace/wait-for.sh", "db", "3307",
      "./packages/workspace/wait-for.sh", "cache", "6379",
      "./packages/workspace/wait-for.sh", "auth", "3000",
      "./packages/workspace/docker/entrypoint.sh", "start-web"
    ]
    env_file: docker/workspace.env
    environment:
      PORT: 3000
      DB_HOST: '${DB_HOST}'
      DB_REPLICA_HOST: '${DB_REPLICA_HOST}'
      DB_PORT: '${DB_PORT}'
      DB_DATABASE: '${DB_DATABASE}'
      DB_USERNAME: '${DB_USERNAME}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_DEBUG_LEVEL: '${DB_DEBUG_LEVEL}'
      DB_MIGRATIONS_PATH: '${DB_MIGRATIONS_PATH}'
      REDIS_URL: '${REDIS_URL}'
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  workspace-worker:
    image: standardnotes/workspace
    container_name: workspace-worker-standalone
    depends_on:
      - db
      - cache
      - workspace
    entrypoint: [
      "./packages/workspace/wait-for.sh", "db", "3307",
      "./packages/workspace/wait-for.sh", "cache", "6379",
      "./packages/workspace/wait-for.sh", "workspace", "3000",
      "./packages/workspace/docker/entrypoint.sh", "start-worker"
    ]
    env_file: docker/workspace.env
    environment:
      PORT: 3000
      DB_HOST: '${DB_HOST}'
      DB_REPLICA_HOST: '${DB_REPLICA_HOST}'
      DB_PORT: '${DB_PORT}'
      DB_DATABASE: '${DB_DATABASE}'
      DB_USERNAME: '${DB_USERNAME}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_DEBUG_LEVEL: '${DB_DEBUG_LEVEL}'
      DB_MIGRATIONS_PATH: '${DB_MIGRATIONS_PATH}'
      REDIS_URL: '${REDIS_URL}'
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
    restart: unless-stopped
    networks:
      - standardnotes_standalone

networks:
  standardnotes_standalone:
    name: standardnotes_standalone
Bizzaro commented 1 year ago

Redis logs

e effect.
1:M 20 Oct 2022 02:06:23.010 * Loading RDB produced by version 6.0.16
1:M 20 Oct 2022 02:06:23.010 * RDB age 13120 seconds
1:M 20 Oct 2022 02:06:23.010 * RDB memory usage when created 0.94 Mb
1:M 20 Oct 2022 02:06:23.010 * DB loaded from disk: 0.001 seconds
1:M 20 Oct 2022 02:06:23.011 * Ready to accept connections
1:C 20 Oct 2022 02:08:40.717 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 20 Oct 2022 02:08:40.717 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 20 Oct 2022 02:08:40.717 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 20 Oct 2022 02:08:40.720 * Running mode=standalone, port=6379.
1:M 20 Oct 2022 02:08:40.720 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 20 Oct 2022 02:08:40.720 # Server initialized
1:M 20 Oct 2022 02:08:40.720 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 20 Oct 2022 02:08:40.722 * Loading RDB produced by version 6.0.16
1:M 20 Oct 2022 02:08:40.722 * RDB age 13257 seconds
1:M 20 Oct 2022 02:08:40.722 * RDB memory usage when created 0.94 Mb
1:M 20 Oct 2022 02:08:40.723 * DB loaded from disk: 0.002 seconds
1:M 20 Oct 2022 02:08:40.723 * Ready to accept connections
Bizzaro commented 1 year ago

mysql logs

Version: '5.6.51'  socket: '/var/run/mysqld/mysqld.sock'  port: 3307  MySQL Community Server (GPL)
2022-10-20 02:08:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.51-1debian9 started.
2022-10-20 02:08:39+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-10-20 02:08:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.51-1debian9 started.
2022-10-20 02:08:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-10-20 02:08:40 0 [Note] mysqld (mysqld 5.6.51) starting as process 1 ...
2022-10-20 02:08:40 1 [Note] Plugin 'FEDERATED' is disabled.
2022-10-20 02:08:40 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
2022-10-20 02:08:40 1 [Note] InnoDB: The InnoDB memory heap is disabled
2022-10-20 02:08:40 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-10-20 02:08:40 1 [Note] InnoDB: Memory barrier is not used
2022-10-20 02:08:40 1 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-10-20 02:08:40 1 [Note] InnoDB: Using Linux native AIO
2022-10-20 02:08:40 1 [Note] InnoDB: Using CPU crc32 instructions
2022-10-20 02:08:40 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2022-10-20 02:08:40 1 [Note] InnoDB: Completed initialization of buffer pool
2022-10-20 02:08:40 1 [Note] InnoDB: Highest supported file format is Barracuda.
2022-10-20 02:08:40 1 [Note] InnoDB: The log sequence numbers 136248766 and 136248766 in ibdata files do not match the log sequence number 164286418 in the ib_logfiles!
2022-10-20 02:08:40 1 [Note] InnoDB: Database was not shutdown normally!
2022-10-20 02:08:40 1 [Note] InnoDB: Starting crash recovery.
2022-10-20 02:08:40 1 [Note] InnoDB: Reading tablespace information from the .ibd files...
2022-10-20 02:08:40 1 [Note] InnoDB: Restoring possible half-written data pages 
2022-10-20 02:08:40 1 [Note] InnoDB: from the doublewrite buffer...
2022-10-20 02:08:40 1 [Note] InnoDB: 128 rollback segment(s) are active.
2022-10-20 02:08:40 1 [Note] InnoDB: Waiting for purge to start
2022-10-20 02:08:40 1 [Note] InnoDB: 5.6.51 started; log sequence number 164286418
2022-10-20 02:08:40 1 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2022-10-20 02:08:40 1 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2022-10-20 02:08:40 1 [Note] Server hostname (bind-address): '*'; port: 3307
2022-10-20 02:08:40 1 [Note] IPv6 is available.
2022-10-20 02:08:40 1 [Note]   - '::' resolves to '::';
2022-10-20 02:08:40 1 [Note] Server socket created on IP: '::'.
2022-10-20 02:08:40 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2022-10-20 02:08:40 1 [Warning] 'proxies_priv' entry '@ root@436ad50cf1cf' ignored in --skip-name-resolve mode.
2022-10-20 02:08:40 1 [Note] Event Scheduler: Loaded 0 events
2022-10-20 02:08:40 1 [Note] mysqld: ready for connections.
Version: '5.6.51'  socket: '/var/run/mysqld/mysqld.sock'  port: 3307  MySQL Community Server (GPL)
Bizzaro commented 1 year ago

fyi... I have a workaround that involves using specific old docker images. The error occurs when everything uses the latest version.

docker-compose.yml

version: '3.8'
services:
  syncing-server-js:
    image: standardnotes/syncing-server-js:5979b9939843e1948b940fdc291133fd89fa756a
    container_name: syncing-server-js-standalone
    depends_on:
      - db
      - cache
    entrypoint: [
      "./packages/syncing-server/wait-for.sh", "db", "3307",
      "./packages/syncing-server/wait-for.sh", "cache", "6379",
      "./packages/syncing-server/docker/entrypoint.sh", "start-web"
    ]
    env_file: .env
    environment:
      PORT: 3000
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  syncing-server-js-worker:
    image: standardnotes/syncing-server-js:5979b9939843e1948b940fdc291133fd89fa756a
    container_name: syncing-server-js-worker-standalone
    depends_on:
      - db
      - cache
      - syncing-server-js
    entrypoint: [
      "./packages/syncing-server/wait-for.sh", "db", "3307",
      "./packages/syncing-server/wait-for.sh", "cache", "6379",
      "./packages/syncing-server/wait-for.sh", "syncing-server-js", "3000",
      "./packages/syncing-server/docker/entrypoint.sh", "start-worker"
    ]
    env_file: .env
    environment:
      PORT: 3000
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  api-gateway:
    image: standardnotes/api-gateway:5979b9939843e1948b940fdc291133fd89fa756a
    container_name: api-gateway-standalone
    depends_on:
      - auth
      - syncing-server-js
    env_file: docker/api-gateway.env
    ports:
      - ${EXPOSED_PORT}:3000
    environment:
      PORT: 3000
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
      REDIS_URL: '${REDIS_URL}'
      FILES_SERVER_URL: '${FILES_SERVER_URL}'
    entrypoint: [
      "./packages/api-gateway/wait-for.sh", "auth", "3000",
      "./packages/api-gateway/wait-for.sh", "syncing-server-js", "3000",
      "./packages/api-gateway/wait-for.sh", "files", "3000",
      "./packages/api-gateway/docker/entrypoint.sh", "start-web"
    ]
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  auth:
    image: standardnotes/auth:5979b9939843e1948b940fdc291133fd89fa756a
    container_name: auth-standalone
    depends_on:
      - db
      - cache
      - syncing-server-js
    entrypoint: [
      "./packages/auth/wait-for.sh", "db", "3307",
      "./packages/auth/wait-for.sh", "cache", "6379",
      "./packages/auth/wait-for.sh", "syncing-server-js", "3000",
      "./packages/auth/docker/entrypoint.sh", "start-web"
    ]
    env_file: docker/auth.env
    environment:
      PORT: 3000
      DB_HOST: '${DB_HOST}'
      DB_REPLICA_HOST: '${DB_REPLICA_HOST}'
      DB_PORT: '${DB_PORT}'
      DB_DATABASE: '${DB_DATABASE}'
      DB_USERNAME: '${DB_USERNAME}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_DEBUG_LEVEL: '${DB_DEBUG_LEVEL}'
      DB_MIGRATIONS_PATH: '${DB_MIGRATIONS_PATH}'
      REDIS_URL: '${REDIS_URL}'
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
      VALET_TOKEN_SECRET: '${VALET_TOKEN_SECRET}'
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  auth-worker:
    image: standardnotes/auth:5979b9939843e1948b940fdc291133fd89fa756a
    container_name: auth-worker-standalone
    depends_on:
      - db
      - cache
      - auth
    entrypoint: [
      "./packages/auth/wait-for.sh", "db", "3307",
      "./packages/auth/wait-for.sh", "cache", "6379",
      "./packages/auth/wait-for.sh", "auth", "3000",
      "./packages/auth/docker/entrypoint.sh", "start-worker"
    ]
    env_file: docker/auth.env
    environment:
      PORT: 3000
      DB_HOST: '${DB_HOST}'
      DB_REPLICA_HOST: '${DB_REPLICA_HOST}'
      DB_PORT: '${DB_PORT}'
      DB_DATABASE: '${DB_DATABASE}'
      DB_USERNAME: '${DB_USERNAME}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_DEBUG_LEVEL: '${DB_DEBUG_LEVEL}'
      DB_MIGRATIONS_PATH: '${DB_MIGRATIONS_PATH}'
      REDIS_URL: '${REDIS_URL}'
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
      VALET_TOKEN_SECRET: '${VALET_TOKEN_SECRET}'
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  files:
    image: standardnotes/files:5979b9939843e1948b940fdc291133fd89fa756a
    container_name: files-standalone
    entrypoint: [
      "./packages/files/wait-for.sh", "db", "3307",
      "./packages/files/wait-for.sh", "cache", "6379",
      "./packages/files/docker/entrypoint.sh", "start-web"
    ]
    ports:
      - ${EXPOSED_FILES_PORT}:3000
    env_file: docker/files.env
    environment:
      FILE_UPLOAD_PATH: '${FILE_UPLOAD_PATH}'
      VALET_TOKEN_SECRET: '${VALET_TOKEN_SECRET}'
    volumes:
      - ./${FILE_UPLOAD_PATH}:/var/www/${FILE_UPLOAD_PATH}
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  db:
    image: mysql:5.6
    container_name: db-standalone
    environment:
      MYSQL_DATABASE: '${DB_DATABASE}'
      MYSQL_USER: '${DB_USERNAME}'
      MYSQL_PASSWORD: '${DB_PASSWORD}'
      MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
      MYSQL_TCP_PORT: 3307
    expose:
      - 3307
    restart: unless-stopped
    command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_general_ci
    volumes:
      - ./data/mysql:/var/lib/mysql
      - ./data/import:/docker-entrypoint-initdb.d
    networks:
      - standardnotes_standalone

  cache:
    image: redis:6.0-alpine
    container_name: cache-standalone
    volumes:
      - ./data/redis/:/data
    expose:
      - 6379
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  workspace:
    image: standardnotes/workspace:9cf746f6afcd01ea5726f7cf0e7430951cf290db
    container_name: workspace-standalone
    depends_on:
      - db
      - cache
      - auth
    entrypoint: [
      "./packages/workspace/wait-for.sh", "db", "3307",
      "./packages/workspace/wait-for.sh", "cache", "6379",
      "./packages/workspace/wait-for.sh", "auth", "3000",
      "./packages/workspace/docker/entrypoint.sh", "start-web"
    ]
    env_file: docker/workspace.env
    environment:
      PORT: 3000
      DB_HOST: '${DB_HOST}'
      DB_REPLICA_HOST: '${DB_REPLICA_HOST}'
      DB_PORT: '${DB_PORT}'
      DB_DATABASE: '${DB_DATABASE}'
      DB_USERNAME: '${DB_USERNAME}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_DEBUG_LEVEL: '${DB_DEBUG_LEVEL}'
      DB_MIGRATIONS_PATH: '${DB_MIGRATIONS_PATH}'
      REDIS_URL: '${REDIS_URL}'
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
    restart: unless-stopped
    networks:
      - standardnotes_standalone

  workspace-worker:
    image: standardnotes/workspace:9cf746f6afcd01ea5726f7cf0e7430951cf290db
    container_name: workspace-worker-standalone
    depends_on:
      - db
      - cache
      - workspace
    entrypoint: [
      "./packages/workspace/wait-for.sh", "db", "3307",
      "./packages/workspace/wait-for.sh", "cache", "6379",
      "./packages/workspace/wait-for.sh", "workspace", "3000",
      "./packages/workspace/docker/entrypoint.sh", "start-worker"
    ]
    env_file: docker/workspace.env
    environment:
      PORT: 3000
      DB_HOST: '${DB_HOST}'
      DB_REPLICA_HOST: '${DB_REPLICA_HOST}'
      DB_PORT: '${DB_PORT}'
      DB_DATABASE: '${DB_DATABASE}'
      DB_USERNAME: '${DB_USERNAME}'
      DB_PASSWORD: '${DB_PASSWORD}'
      DB_DEBUG_LEVEL: '${DB_DEBUG_LEVEL}'
      DB_MIGRATIONS_PATH: '${DB_MIGRATIONS_PATH}'
      REDIS_URL: '${REDIS_URL}'
      AUTH_JWT_SECRET: '${AUTH_JWT_SECRET}'
    restart: unless-stopped
    networks:
      - standardnotes_standalone

networks:
  standardnotes_standalone:
          name: standardnotes_standalone
jackyzy823 commented 1 year ago

It looks like something related to proxy stuff or self-signed certificates stuff in the network

Ref: https://github.com/nodejs/corepack/issues/67

karolsojko commented 1 year ago

Should be fixed with the latest version - can you check ?

homberger commented 1 year ago

Why was the workspaces container and its env.sample file removed?

Pulling changes from Git.
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 6 (delta 5), reused 6 (delta 5), pack-reused 0
Unpacking objects: 100% (6/6), 1.02 KiB | 80.00 KiB/s, done.
From https://github.com/standardnotes/standalone
 * branch            main       -> FETCH_HEAD
   13c5de2..65caaf7  main       -> origin/main
Updating 13c5de2..65caaf7
Fast-forward
 .gitignore                  |  1 -
 docker-compose.yml          | 60 ------------------------------------------------------------
 docker/workspace.env.sample | 10 ----------
 server.sh                   |  6 ------
 4 files changed, 77 deletions(-)
 delete mode 100644 docker/workspace.env.sample
Checking for env file changes
wc: docker/workspace.env.sample: No such file or directory
./server.sh: 48: [: Illegal number:
Downloading latest images of Standard Notes services.
[+] Running 28/28
 ⠿ auth-worker Skipped - Image is already being pulled by auth                                                                                                                                              0.0s
 ⠿ syncing-server-js Skipped - Image is already being pulled by syncing-server-js-worker                                                                                                                    0.0s
 ⠿ cache Pulled                                                                                                                                                                                             1.2s
 ⠿ syncing-server-js-worker Pulled                                                                                                                                                                         10.5s
   ⠿ 2ecf7cf5378b Pull complete                                                                                                                                                                             4.4s
   ⠿ 190b9d3761aa Pull complete                                                                                                                                                                             4.4s
   ⠿ 9274e5e8e9a6 Pull complete                                                                                                                                                                             4.5s
   ⠿ fe24a52d5e5a Pull complete                                                                                                                                                                             8.6s
 ⠿ files Pulled                                                                                                                                                                                            10.6s
   ⠿ ca7dd9ec2225 Already exists                                                                                                                                                                            0.0s
   ⠿ 55371e6747e8 Already exists                                                                                                                                                                            0.0s
   ⠿ 694d6b1b2d1b Already exists                                                                                                                                                                            0.0s
   ⠿ fda52be0ff10 Pull complete                                                                                                                                                                             3.5s
   ⠿ c61cfdff0281 Pull complete                                                                                                                                                                             3.7s
   ⠿ ae50691c3287 Pull complete                                                                                                                                                                             4.2s
   ⠿ c4d5e06fcfe4 Pull complete                                                                                                                                                                             8.7s
 ⠿ auth Pulled                                                                                                                                                                                              7.2s
   ⠿ 7a5210542a82 Pull complete                                                                                                                                                                             2.4s
   ⠿ 4721ced327c2 Pull complete                                                                                                                                                                             2.4s
   ⠿ e5bb0617a8e2 Pull complete                                                                                                                                                                             2.6s
   ⠿ 6cf45e525cf9 Pull complete                                                                                                                                                                             5.3s
 ⠿ db Pulled                                                                                                                                                                                                1.2s
 ⠿ api-gateway Pulled                                                                                                                                                                                       6.2s
   ⠿ 71f41f5ff77d Already exists                                                                                                                                                                            0.0s
   ⠿ dc911cc722e0 Pull complete                                                                                                                                                                             2.3s
   ⠿ 2a72523ff1f0 Pull complete                                                                                                                                                                             2.4s
   ⠿ 244fd66810f6 Pull complete                                                                                                                                                                             2.5s
   ⠿ 413782ded073 Pull complete                                                                                                                                                                             4.3s
Images up to date. Starting all services.
WARN[0000] Found orphan containers ([workspace-worker-standalone workspace-standalone]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
[+] Running 8/8
 ⠿ Container files-standalone                     Started                                                                                                                                                   1.4s
 ⠿ Container cache-standalone                     Started                                                                                                                                                   1.5s
 ⠿ Container db-standalone                        Started                                                                                                                                                   1.6s
 ⠿ Container syncing-server-js-standalone         Started                                                                                                                                                   2.0s
 ⠿ Container auth-standalone                      Started                                                                                                                                                   3.6s
 ⠿ Container syncing-server-js-worker-standalone  Started                                                                                                                                                   3.8s
 ⠿ Container auth-worker-standalone               Started                                                                                                                                                   5.5s
 ⠿ Container api-gateway-standalone               Started
karolsojko commented 1 year ago

Why was the workspaces container and its env.sample file removed?

We are putting the workspaces project on the back burner for now

917huB commented 1 year ago

I tried to update to :latest and still had problems starting my containers.

# journalctl -f -u snotes-server-js
Dec 01 17:20:08 dockerhost docker[623783]: Internal Error: Error when performing the request
Dec 01 17:20:08 dockerhost docker[623783]:     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:3937:20)
Dec 01 17:20:08 dockerhost docker[623783]:     at ClientRequest.emit (node:events:527:28)
Dec 01 17:20:08 dockerhost docker[623783]:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
Dec 01 17:20:08 dockerhost docker[623783]:     at TLSSocket.emit (node:events:527:28)
Dec 01 17:20:08 dockerhost docker[623783]:     at emitErrorNT (node:internal/streams/destroy:157:8)
Dec 01 17:20:08 dockerhost docker[623783]:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
Dec 01 17:20:08 dockerhost docker[623783]:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
Dec 01 17:20:09 dockerhost systemd[1]: snotes-server-js.service: Main process exited, code=exited, status=1/FAILURE
karolsojko commented 1 year ago

@917huB try putting to log level to debug in env vars of syncing server container - maybe there'll be some more context

917huB commented 1 year ago

sorry @karolsojko , no additional items were logged.

Dec 02 17:04:20 dockerhost systemd[1]: Stopping docker for standardnotes-js server worker...
Dec 02 17:04:20 dockerhost docker[2639533]: Starting Web...
Dec 02 17:04:21 dockerhost docker[2639533]: Internal Error: Error when performing the request
Dec 02 17:04:21 dockerhost docker[2639533]:     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:3937:20)
Dec 02 17:04:21 dockerhost docker[2639533]:     at ClientRequest.emit (node:events:527:28)
Dec 02 17:04:21 dockerhost docker[2639533]:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
Dec 02 17:04:21 dockerhost docker[2639533]:     at TLSSocket.emit (node:events:527:28)
Dec 02 17:04:21 dockerhost docker[2639533]:     at emitErrorNT (node:internal/streams/destroy:157:8)
Dec 02 17:04:21 dockerhost docker[2639533]:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
Dec 02 17:04:21 dockerhost docker[2639533]:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
Dec 02 17:04:21 dockerhost docker[2640201]: snotes-server-js-worker
Dec 02 17:04:21 dockerhost systemd[1]: snotes-server-js-worker.service: Main process exited, code=exited, status=1/FAILURE
Dec 02 17:04:21 dockerhost systemd[1]: snotes-server-js-worker.service: Failed with result 'exit-code'.
Dec 02 17:04:21 dockerhost systemd[1]: Stopped docker for standardnotes-js server worker.
FlorianEndel commented 1 year ago

I just ran into the same problem with the current :latest tag. In my case, the API-Gateway threw a nearly identical error.

Starting Web...
Internal Error: Error when performing the request
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:16064:20)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:494:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

There is no additional information when changing logging to debug.

Changing back to previous versions also didn't help.

The service started again after setting an explicit DNS (remote or local):

    dns:
      - 1.1.1.1
jackyzy823 commented 1 year ago

I thinks it is definitely a network related (dns/proxy/vpn/self-signed cert/DPI) issue.

Here's a method for checking steps:

  1. spawn a container docker run --rm -it --entrypoint=/bin/sh standardnotes/api-gateway
  2. in shell do: sed -i '/Error when performing the request/c reject(err);' /usr/local/lib/node_modules/corepack/dist/corepack.js to show more detailed error .
  3. in shell do ./packages/api-gateway/docker/entrypoint.sh start-web to observe what really happens.

it will show more detailed error like

Internal Error: getaddrinfo EAI_AGAIN repo.yarnpkg.com
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)

(when i spwan container with --network=none)

jackyzy823 commented 1 year ago

The probable root cause is that when container starts , corepack wants to download missing yarn from internet . So if your docker or network env do not have access to internet , corepack will fail.

So i recommend @karolsojko to update all server's Dockerfile adding corepack yarn (why not using corepack prepare ref : https://github.com/nodejs/corepack/issues/96) after corepack enable to pre-download yarn in the docker image for those who host standardnotes in the intranet/lan.

And for selfhosters who has no internet access, after developers update all docker image to contains yarn , set enviornment COREPACK_ENABLE_NETWORK=0 in docker-compose to avoid furture fail (like corepack want update yarn etc ...) .