Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update production environment documentation #794

Draft
wants to merge 48 commits into
base: master
Choose a base branch
from

Conversation

edwardchalstrey1
Copy link
Contributor

@edwardchalstrey1 edwardchalstrey1 commented Mar 1, 2022

Changes

Updates and fixes the colouring-london doc for setting up the website on a server.

View rendered md

TODO:

  • Get application to run on test Azure VM with these instructions
  • Set up DB Backups CRON
  • Set up data extracts/maintenance CRON
  • Set up Set up SSL (see todos in doc)
  • [ ] Combine this doc with the dev doc to avoid duplication of sections EC edit: I think there are enough differences to justify separate docs

@edwardchalstrey1
Copy link
Contributor Author

edwardchalstrey1 commented Mar 3, 2022

@matkoniecz @tomalrussell I've continued from where we left off on Tuesday today, however I'm still unable to get the application to be visible at the IP address with either npm run start:prod (here in doc) or with pm2 start ecosystem.config.js here in doc, but neither way are any errors being thrown, so I'm unsure how to proceed. Do either of you have any ideas of what to try next?

As for the backups, maintenance & domain steps at the end of the doc I've just added placeholders for now. I notice that in ecosystem.config.dev-template.js we have extra env vars compared to what the doc says to include, e.g. MAIL_SERVER_HOST, but from looking at the config repo readme, I don't think I'll need these until I set up a server email, and a domain for the. WEBAPP_ORIGIN etc

@matkoniecz
Copy link
Contributor

matkoniecz commented Mar 3, 2022

would try pm2 status pm2 logs sudo -u nodeapp pm2 status sudo -u nodeapp pm2 logs for start if not tried already (https://github.com/colouring-cities/colouring-london-config#deployment)

@edwardchalstrey1
Copy link
Contributor Author

pm2 logs

Ok yes thanks this has found a problem, I think this must be the important line 4|colourin | Error: Cannot find module '/var/www/colouring-london/app/build/server.js'

@tomalrussell
Copy link
Contributor

Have you built the app successfully (npm run build) and is server.js at the expected location?

@edwardchalstrey1
Copy link
Contributor Author

edwardchalstrey1 commented Mar 3, 2022

Have you built the app successfully (npm run build) and is server.js at the expected location?

@tomalrussell yep it's there, and pm2 status shows the 6 instances specified in ecosystem.config.js as status online

Full readout of pm2 logs looks like this:

azureuser@cl-test-server:/var/www/colouring-london$ pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/home/azureuser/.pm2/pm2.log last 15 lines:
PM2        | 2022-03-03T15:51:05: PM2 log: App [colouringlondon:5] exited with code [0] via signal [SIGINT]
PM2        | 2022-03-03T15:51:05: PM2 log: pid=28591 msg=process killed
PM2        | 2022-03-03T15:51:05: PM2 log: pid=28592 msg=process killed
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:0] starting in -cluster mode-
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:1] starting in -cluster mode-
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:0] online
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:2] starting in -cluster mode-
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:1] online
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:3] starting in -cluster mode-
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:2] online
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:3] online
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:4] starting in -cluster mode-
PM2        | 2022-03-03T15:54:03: PM2 log: App [colouringlondon:5] starting in -cluster mode-
PM2        | 2022-03-03T15:54:04: PM2 log: App [colouringlondon:5] online
PM2        | 2022-03-03T15:54:04: PM2 log: App [colouringlondon:4] online

/home/azureuser/.pm2/logs/colouringlondon-error-0.log last 15 lines:
0|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
0|colourin |     at WriteStream.emit (node:events:390:28)
0|colourin |     at node:internal/fs/streams:72:16
0|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)
0|colourin | Error: Cannot find module '/var/www/colouring-london/app/build/server.js'
0|colourin |     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
0|colourin |     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
0|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/ProcessContainer.js:303:25
0|colourin |     at wrapper (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/once.js:12:16)
0|colourin |     at next (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/waterfall.js:96:20)
0|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
0|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
0|colourin |     at WriteStream.emit (node:events:390:28)
0|colourin |     at node:internal/fs/streams:72:16
0|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)

/home/azureuser/.pm2/logs/colouringlondon-error-1.log last 15 lines:
1|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
1|colourin |     at WriteStream.emit (node:events:390:28)
1|colourin |     at node:internal/fs/streams:72:16
1|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)
1|colourin | Error: Cannot find module '/var/www/colouring-london/app/build/server.js'
1|colourin |     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
1|colourin |     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
1|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/ProcessContainer.js:303:25
1|colourin |     at wrapper (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/once.js:12:16)
1|colourin |     at next (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/waterfall.js:96:20)
1|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
1|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
1|colourin |     at WriteStream.emit (node:events:390:28)
1|colourin |     at node:internal/fs/streams:72:16
1|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)

/home/azureuser/.pm2/logs/colouringlondon-error-5.log last 15 lines:
5|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
5|colourin |     at WriteStream.emit (node:events:390:28)
5|colourin |     at node:internal/fs/streams:72:16
5|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)
5|colourin | Error: Cannot find module '/var/www/colouring-london/app/build/server.js'
5|colourin |     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
5|colourin |     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
5|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/ProcessContainer.js:303:25
5|colourin |     at wrapper (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/once.js:12:16)
5|colourin |     at next (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/waterfall.js:96:20)
5|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
5|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
5|colourin |     at WriteStream.emit (node:events:390:28)
5|colourin |     at node:internal/fs/streams:72:16
5|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)

/home/azureuser/.pm2/logs/colouringlondon-error-3.log last 15 lines:
3|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
3|colourin |     at WriteStream.emit (node:events:390:28)
3|colourin |     at node:internal/fs/streams:72:16
3|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)
3|colourin | Error: Cannot find module '/var/www/colouring-london/app/build/server.js'
3|colourin |     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
3|colourin |     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
3|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/ProcessContainer.js:303:25
3|colourin |     at wrapper (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/once.js:12:16)
3|colourin |     at next (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/waterfall.js:96:20)
3|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
3|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
3|colourin |     at WriteStream.emit (node:events:390:28)
3|colourin |     at node:internal/fs/streams:72:16
3|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)

/home/azureuser/.pm2/logs/colouringlondon-error-2.log last 15 lines:
2|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
2|colourin |     at WriteStream.emit (node:events:390:28)
2|colourin |     at node:internal/fs/streams:72:16
2|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)
2|colourin | Error: Cannot find module '/var/www/colouring-london/app/build/server.js'
2|colourin |     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2|colourin |     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/ProcessContainer.js:303:25
2|colourin |     at wrapper (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/once.js:12:16)
2|colourin |     at next (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/waterfall.js:96:20)
2|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
2|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
2|colourin |     at WriteStream.emit (node:events:390:28)
2|colourin |     at node:internal/fs/streams:72:16
2|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)

/home/azureuser/.pm2/logs/colouringlondon-error-4.log last 15 lines:
4|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
4|colourin |     at WriteStream.emit (node:events:390:28)
4|colourin |     at node:internal/fs/streams:72:16
4|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)
4|colourin | Error: Cannot find module '/var/www/colouring-london/app/build/server.js'
4|colourin |     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
4|colourin |     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
4|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/ProcessContainer.js:303:25
4|colourin |     at wrapper (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/once.js:12:16)
4|colourin |     at next (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/waterfall.js:96:20)
4|colourin |     at /usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
4|colourin |     at WriteStream.<anonymous> (/usr/local/lib/node/node-v16.13.2/lib/node_modules/pm2/lib/Utility.js:186:13)
4|colourin |     at WriteStream.emit (node:events:390:28)
4|colourin |     at node:internal/fs/streams:72:16
4|colourin |     at FSReqCallback.oncomplete (node:fs:188:23)

/home/azureuser/.pm2/logs/colouringlondon-out-0.log last 15 lines:
0|colourin | 🚀  started
0|colourin | 🚀  started
0|colourin | 🚀  started
0|colourin | 🚀  started
0|colourin | 🚀  started
0|colourin | 🚀  started
0|colourin | 🚀  started
0|colourin | 🚀  started

/home/azureuser/.pm2/logs/colouringlondon-out-1.log last 15 lines:
1|colourin | 🚀  started
1|colourin | 🚀  started
1|colourin | 🚀  started
1|colourin | 🚀  started
1|colourin | 🚀  started
1|colourin | 🚀  started
1|colourin | 🚀  started
1|colourin | 🚀  started

/home/azureuser/.pm2/logs/colouringlondon-out-2.log last 15 lines:
2|colourin | 🚀  started
2|colourin | 🚀  started
2|colourin | 🚀  started
2|colourin | 🚀  started
2|colourin | 🚀  started
2|colourin | 🚀  started
2|colourin | 🚀  started
2|colourin | 🚀  started

/home/azureuser/.pm2/logs/colouringlondon-out-3.log last 15 lines:
3|colourin | 🚀  started
3|colourin | 🚀  started
3|colourin | 🚀  started
3|colourin | 🚀  started
3|colourin | 🚀  started
3|colourin | 🚀  started
3|colourin | 🚀  started
3|colourin | 🚀  started

/home/azureuser/.pm2/logs/colouringlondon-out-4.log last 15 lines:
4|colourin | 🚀  started
4|colourin | 🚀  started
4|colourin | 🚀  started
4|colourin | 🚀  started
4|colourin | 🚀  started
4|colourin | 🚀  started
4|colourin | 🚀  started
4|colourin | 🚀  started

/home/azureuser/.pm2/logs/colouringlondon-out-5.log last 15 lines:
5|colourin | 🚀  started
5|colourin | 🚀  started
5|colourin | 🚀  started
5|colourin | 🚀  started
5|colourin | 🚀  started
5|colourin | 🚀  started
5|colourin | 🚀  started
5|colourin | 🚀  started

@edwardchalstrey1
Copy link
Contributor Author

By the way, one thing I have changed since Tuesday is that I symlinked the whole CL repo, so /var/www/colouring-london points to ~/colouring-london, where the repo is cloned.

@tomalrussell
Copy link
Contributor

tomalrussell commented Mar 3, 2022

symlinked the whole CL repo

I'd be surprised if this is causing problems, but would suggest that we end up not doing that, so we can build outside of the live directory, and minimise downtime on redeployment, moving the updated code into place and restarting. If what you have in place is helpful while testing, keep going.

Quick reading suggests the error might be linked to ESM module resolution changes - see https://stackoverflow.com/questions/65384754/error-err-module-not-found-cannot-find-module and Unitech/pm2#4540

Could try:

  • try cd to the build dir and start with node server.js and/or node --experimental-specifier-resolution=node server.js
  • suggested rename to ecosystem.config.cjs (with a c) and pm2 start ecosystem.config.cjs
  • add a NODE_OPTIONS='--experimental-specifier-resolution=node' environment variable

@edwardchalstrey1 edwardchalstrey1 moved this from To do: Ordered priorities to Development Backlog: Everything that we want to add to the platform but is not a priority in 2022 Turing Research Engineering - Colouring London Development Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
2022 Turing Research Engineering - Co...
Development Backlog: Everything that ...
Development

Successfully merging this pull request may close these issues.

None yet

3 participants