claabs / epicgames-freegames-node

Automatically login and find available free games the Epic Games Store. Sends you a prepopulated checkout link so you can complete the checkout after logging in. Supports multiple accounts, login sessions, and scheduled runs.
https://hub.docker.com/r/charlocharlie/epicgames-freegames
MIT License
1.33k stars 90 forks source link

No config file detected after the first execution #163

Closed TychoTheTaco closed 2 years ago

TychoTheTaco commented 2 years ago

The app can't find the config file after the first time it runs. I have runOnStartup = true, which works fine, but then later when it gets triggered by the cron schedule, it fails to find the config. I'm starting the app with: docker run -d -v "/mnt/Main/Epic Games Claimer":/usr/app/config:rw -p 3000:3000 charlocharlie/epicgames-freegames:latest Here are the logs:

> epicgames-freegames-node@4.0.0 entrypoint-config /usr/app
> node dist/src/entrypoint-config.js

Setting timezone: UTC
Run on startup: true
[2021-10-08 22:52:41.215 +0000] INFO  (43 on d988f7ebf27d): Checking free games for my@email.com 
[2021-10-08 22:52:47.361 +0000] INFO  (43 on d988f7ebf27d): Successfully refreshed login
    user: "my@email.com"
[2021-10-08 22:52:50.895 +0000] INFO  (43 on d988f7ebf27d): Available free games
    user: "my@email.com"
    availableGames: [
      "PC Building Simulator"
    ]
[2021-10-08 22:52:51.374 +0000] INFO  (43 on d988f7ebf27d): Unpurchased free games
    user: "my@email.com"
    purchasableGames: [
      "PC Building Simulator"
    ]
[2021-10-08 22:52:51.374 +0000] INFO  (43 on d988f7ebf27d): Purchasing PC Building Simulator
[2021-10-08 22:52:54.299 +0000] INFO  (43 on d988f7ebf27d): Done purchasing PC Building Simulator
Run once: false
Setting cron schedule as 0 12 * * *
[2021-10-09 12:00:00.917 +0000] WARN  (57 on d988f7ebf27d): No config file detected
[2021-10-09 12:00:00.924 +0000] INFO  (57 on d988f7ebf27d): Not allowed to create new config. Continuing...
[2021-10-09 12:00:00.929 +0000] ERROR (57 on d988f7ebf27d): Validation error(s)
    errors: [
      {
        "property": "accounts",
        "children": [],
        "constraints": {
          "arrayNotEmpty": "accounts should not be empty",
          "isArray": "accounts must be an array"
        }
      }
    ]
Error: Invalid config
    at Object.<anonymous> (/usr/app/src/common/config/setup.ts:104:9)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/usr/app/src/common/config/index.ts:2:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
claabs commented 2 years ago

Can you set "logLevel": "debug"? Hopefully that will show the reason it can't read/write. You can set "cronSchedule": "* * * * *" to get it to run every minute.

TychoTheTaco commented 2 years ago

Unfortunately it doesn't show any extra info related to the config file:

> epicgames-freegames-node@4.0.0 entrypoint-config /usr/app
> node dist/src/entrypoint-config.js

Setting timezone: UTC
Run on startup: true
[2021-10-11 20:04:56.670 +0000] INFO  (55 on c79c18899ee5): Checking free games for my@email.com 
[2021-10-11 20:04:56.679 +0000] DEBUG (55 on c79c18899ee5): Refreshing login session
    user: "my@email.com"
[2021-10-11 20:05:04.364 +0000] INFO  (55 on c79c18899ee5): Successfully refreshed login
    user: "my@email.com"
[2021-10-11 20:05:04.366 +0000] DEBUG (55 on c79c18899ee5): Getting global free games
    user: "my@email.com"
[2021-10-11 20:05:08.902 +0000] DEBUG (55 on c79c18899ee5): Retrieved catalog data for 202 games
    user: "my@email.com"
[2021-10-11 20:05:08.903 +0000] DEBUG (55 on c79c18899ee5): Found 1 unique free games in catalog
    user: "my@email.com"
[2021-10-11 20:05:08.903 +0000] INFO  (55 on c79c18899ee5): Available free games
    user: "my@email.com"
    availableGames: [
      "PC Building Simulator"
    ]
[2021-10-11 20:05:08.904 +0000] DEBUG (55 on c79c18899ee5): Checking ownership on available games
    user: "my@email.com"
[2021-10-11 20:05:08.904 +0000] DEBUG (55 on c79c18899ee5): Getting product ownership info
    user: "my@email.com"
    offerId: "7bfbb022d2fa4d67a4844631ecd5c027"
    namespace: "8f5f5eff22f3468fa5551771406fc868"
[2021-10-11 20:05:09.460 +0000] INFO  (55 on c79c18899ee5): Unpurchased free games
    user: "my@email.com"
    purchasableGames: []
Run once: false
Setting cron schedule as * * * * *
[2021-10-11 20:06:00.891 +0000] WARN  (69 on c79c18899ee5): No config file detected
[2021-10-11 20:06:00.900 +0000] INFO  (69 on c79c18899ee5): Not allowed to create new config. Continuing...
[2021-10-11 20:06:00.906 +0000] ERROR (69 on c79c18899ee5): Validation error(s)
    errors: [
      {
        "property": "accounts",
        "children": [],
        "constraints": {
          "arrayNotEmpty": "accounts should not be empty",
          "isArray": "accounts must be an array"
        }
      }
    ]
Error: Invalid config
    at Object.<anonymous> (/usr/app/src/common/config/setup.ts:104:9)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/usr/app/src/common/config/index.ts:2:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
claabs commented 2 years ago

Oh duh, setting logLevel in the config.json wouldn't work. Can you set it via environment variable in your Docker config? LOG_LEVEL=debug

TychoTheTaco commented 2 years ago

This time there is more output:

> epicgames-freegames-node@4.0.0 entrypoint-config /usr/app
> node dist/src/entrypoint-config.js

[2021-10-11 20:45:17.067 +0000] DEBUG (25 on 88ae3e8c880e):
    configPath: "/usr/app/config/config.json"
[2021-10-11 20:45:17.124 +0000] DEBUG (25 on 88ae3e8c880e):
    config: {
      "cronSchedule": "* * * * *",
      "searchStrategy": "promotion",
      "runOnStartup": true,
      "runOnce": false,
      "timezone": "UTC",
      "intervalTime": 60,
      "logLevel": "debug",
      "puppeteerPurchase": false,
      "notificationTimeoutHours": 24,
      "testNotifiers": false,
      "accounts": [
        {
          "email": "my@email.com",
          "password": "password"
        }
      ],
      "notifiers": [
        {
          "type": "email",
          "secure": true,
          "smtpHost": "smtp.gmail.com",
          "smtpPort": 465,
          "emailSenderAddress": "my@email.com",
          "emailSenderName": "Epic Games Captchas",
          "emailRecipientAddress": "my@email.com",
          "auth": {
            "user": "my@email.com",
            "pass": "password"
          }
        }
      ],
      "webPortalConfig": {
        "baseUrl": "http://localhost:3000"
      }
    }
Setting timezone: UTC
Run on startup: true
[2021-10-11 20:45:18.213 +0000] DEBUG (53 on 88ae3e8c880e):
    configPath: "/usr/app/config/config.json"
[2021-10-11 20:45:18.245 +0000] DEBUG (53 on 88ae3e8c880e):
    config: {
      "cronSchedule": "* * * * *",
      "searchStrategy": "promotion",
      "runOnStartup": true,
      "runOnce": false,
      "timezone": "UTC",
      "intervalTime": 60,
      "logLevel": "debug",
      "puppeteerPurchase": false,
      "notificationTimeoutHours": 24,
      "testNotifiers": false,
      "accounts": [
        {
          "email": "my@email.com",
          "password": "password"
        }
      ],
      "notifiers": [
        {
          "type": "email",
          "secure": true,
          "smtpHost": "smtp.gmail.com",
          "smtpPort": 465,
          "emailSenderAddress": "my@email.com",
          "emailSenderName": "Epic Games Captchas",
          "emailRecipientAddress": "my@email.com",
          "auth": {
            "user": "my@email.com",
            "pass": "password"
          }
        }
      ],
      "webPortalConfig": {
        "baseUrl": "http://localhost:3000"
      }
    }
[2021-10-11 20:45:19.354 +0000] INFO  (53 on 88ae3e8c880e): Checking free games for my@email.com 
[2021-10-11 20:45:19.359 +0000] DEBUG (53 on 88ae3e8c880e): Refreshing login session
    user: "my@email.com"
[2021-10-11 20:45:27.187 +0000] INFO  (53 on 88ae3e8c880e): Successfully refreshed login
    user: "my@email.com"
[2021-10-11 20:45:27.188 +0000] DEBUG (53 on 88ae3e8c880e): Getting global free games
    user: "my@email.com"
[2021-10-11 20:45:31.321 +0000] DEBUG (53 on 88ae3e8c880e): Retrieved catalog data for 202 games
    user: "my@email.com"
[2021-10-11 20:45:31.321 +0000] DEBUG (53 on 88ae3e8c880e): Found 1 unique free games in catalog
    user: "my@email.com"
[2021-10-11 20:45:31.322 +0000] INFO  (53 on 88ae3e8c880e): Available free games
    user: "my@email.com"
    availableGames: [
      "PC Building Simulator"
    ]
[2021-10-11 20:45:31.323 +0000] DEBUG (53 on 88ae3e8c880e): Checking ownership on available games
    user: "my@email.com"
[2021-10-11 20:45:31.324 +0000] DEBUG (53 on 88ae3e8c880e): Getting product ownership info
    user: "my@email.com"
    offerId: "7bfbb022d2fa4d67a4844631ecd5c027"
    namespace: "8f5f5eff22f3468fa5551771406fc868"
[2021-10-11 20:45:33.219 +0000] INFO  (53 on 88ae3e8c880e): Unpurchased free games
    user: "my@email.com"
    purchasableGames: []
Run once: false
Setting cron schedule as * * * * *
[2021-10-11 20:46:00.653 +0000] WARN  (67 on 88ae3e8c880e): No config file detected
[2021-10-11 20:46:00.657 +0000] DEBUG (67 on 88ae3e8c880e): Creating new config file
    newConfigPath: "/root/config/config.json"
[2021-10-11 20:46:00.662 +0000] DEBUG (67 on 88ae3e8c880e): ENOENT: no such file or directory, open '/root/config/config.json'
    Error: ENOENT: no such file or directory, open '/root/config/config.json'
        at Object.openSync (fs.js:497:3)
        at Object.writeFileSync (fs.js:1528:35)
        at Object.writeFileSync (/usr/app/node_modules/jsonfile/index.js:78:13)
        at Object.<anonymous> (/usr/app/src/common/config/setup.ts:48:8)
        at Module._compile (internal/modules/cjs/loader.js:1085:14)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
        at Module.load (internal/modules/cjs/loader.js:950:32)
        at Function.Module._load (internal/modules/cjs/loader.js:790:12)
        at Module.require (internal/modules/cjs/loader.js:974:19)
        at require (internal/modules/cjs/helpers.js:93:18)
[2021-10-11 20:46:00.684 +0000] INFO  (67 on 88ae3e8c880e): Not allowed to create new config. Continuing...
[2021-10-11 20:46:00.691 +0000] ERROR (67 on 88ae3e8c880e): Validation error(s)
    errors: [
      {
        "property": "accounts",
        "children": [],
        "constraints": {
          "arrayNotEmpty": "accounts should not be empty",
          "isArray": "accounts must be an array"
        }
      }
    ]
Error: Invalid config
    at Object.<anonymous> (/usr/app/src/common/config/setup.ts:104:9)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/usr/app/src/common/config/index.ts:2:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
claabs commented 2 years ago

ENOENT: no such file or directory, open '/root/config/config.json' is what I was looking for. Just a regression from a previous bugfix.

When the build finishes, pull the image and try again, please.

TychoTheTaco commented 2 years ago

It is working now, thanks!