jbrun001 / roombooking

Creative Commons Zero v1.0 Universal
1 stars 1 forks source link

Planet scale hobby tier is closing down on 9 April which is the deadline for the project. The database will need to be moved before we submit the project. #46

Closed jbrun001 closed 7 months ago

jbrun001 commented 7 months ago

Investigated cloud services that were free or had trials for the period of review for the project. A cloud service helps the development process, it means that all developers can access the database at the same time and they can work locally on the code, only needing to push source changes to github. Other cloud offerings are available - for example google cloud offers $300 worth of free hosting for 90 days. However this may require re-work of the connection code for the database but also all the file storage code, because google apps only use google drive for file storage, not filesystem storage. With the deadline approaching the sensible thing to do is to host with GS for the app and the database. Prove this works. This means there is a working solution in place. This is a better option at this point than trying to re-implement on a cloud platform which has no guarantees in the timeframe. Hosting at GS means that testing becomes very hard for the development team. So I propose that the development continues on the development platform planetscale.

  1. The working app and database be installed in the production location which is GS.
  2. The process of switching over is documented and tested.
  3. Git is installed at GS so it can pull the changes. 3.5. all express modules will be installed in GS as a check that these are available
  4. The database export and any changes to the database scripts are tested and documented (so they can be run later)
  5. The app.js is changed so it looks for a GS= variable in the .env, if it finds one it will set up the database connection for GS. if it doesn't find this variable it will setup the database connection for planetscale. the .env is not in github so this will mean that a manual .env can be created in GS to prove that the app will work but this will not stop the development team using planetscale.
  6. When the development is complete a git pull origin main will be executed from GS which will get all up to date code.
  7. A database dump will be performed from planetscale and this will be altered based on the documentation
jbrun001 commented 7 months ago

database successfully imported to uni server

jbrun001 commented 7 months ago

git set up and code pulled from git to uni servers

jbrun001 commented 7 months ago

Problem with bcyrpt npm install on uni servers. Likely to do with versions being out of date. Under review. Various solutions found online. One is to upgrade the version of ubuntu - I'd rather avoid that with it being end of term Another is to uninstall node and re-install it using nvm - this I might try. npm ERR! code 1 npm ERR! path /home/jbrun001/project/roombooking/node_modules/bcrypt npm ERR! command failed npm ERR! command sh /tmp/install-9d46bc39.sh npm ERR! node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)

31/03 update from research into Issue #47 https://github.com/nodesource/distributions/issues/1392 which details the issue. node 18 was compiled on a later version of ubutu and even though it doesn't need GLIBC_2.28 because it was orginally compiled on a machine that had it, it means that you have to have it to run it. only ubuntu 20 has this library.

jbrun001 commented 7 months ago

Attempted to upgrade ubuntu from 18.04 to 20.04. After a research here are the steps that were taken sudo apt update

jbrun001 commented 7 months ago

Remaining options in action order:

The developer environment is using v18.18.1 but this is not available on ubuntu 18.04.x PS D:\Yr02 Computing Project\git\roombooking> node -v v18.18.1

Current versions: jbrun001@doc215:~$ nvm -v
0.39.5
jbrun001@doc215:~$ node -v
v16.17.0
jbrun001@doc215:~$ npm -v
8.15.0
jbrun001@doc215:~$ hostnamectl
Static hostname: doc215
Icon name: computer-vm
Chassis: vm
Machine ID: 78d7d469d6b892d474201e4c38b0473b
Boot ID: 2e58b7ff709945488d25f1df778a4124
Virtualization: kvm
Operating System: Ubuntu 18.04.6 LTS
Kernel: Linux 4.15.0-163-generic
jbrun001@doc215:~$ x86-64 jbrun001@doc215:~$ df -h Filesystem Size Used Avail Use% Mounted on udev 217M 0 217M 0% /dev tmpfs 49M 688K 48M 2% /run /dev/mapper/vg-root 3.5G 3.3G 74M 98% / tmpfs 241M 0 241M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 241M 0 241M 0% /sys/fs/cgroup /dev/vda1 461M 123M 315M 28% /boot tmpfs 49M 0 49M 0% /run/user/1000 jbrun001@doc215:~$

jbrun001 commented 7 months ago

Find out what version of GLIBC is installed on GS server jbrun001@doc215:~$ ldd --version dd (Ubuntu GLIBC 2.27-3ubuntu1.6) 2.27
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
jbrun001@doc215:~$

find out what versions of node are already installed (not the currently used one but any that are installed) jbrun001@doc215:~$ nvm ls
-> v16.17.0 system default -> v16.17.0 iojs -> N/A (default) unstable -> N/A (default) node -> stable (-> v16.17.0) (default) stable -> 16.17 (-> v16.17.0) (default) lts/* -> lts/hydrogen (-> N/A) lts/argon -> v4.9.1 (-> N/A) lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.24.1 (-> N/A) lts/erbium -> v12.22.12 (-> N/A) lts/fermium -> v14.21.3 (-> N/A) lts/gallium -> v16.20.2 (-> N/A) lts/hydrogen -> v18.18.0 (-> N/A) jbrun001@doc215:~$ So we have 2.27 GLIBC and node 16.17.0

Try installing node 16.15.1 via nvm - keeping the existing version in place so we can go back to it if needed jbrun001@doc215:~$ nvm install 16.15.1 This results in not enough space errors. examples are deps/openssl: Cannot mkdir: No space left on device /lib Cannot mkdir: No space left on device

From what I can tell it's not meant to be installing node in /lib etc. it's meant to be installing it in /home/jbrun001. It looks like the "system" version of node is what's installed. This is very strange because in my forum assignment I used bcrypt and it installed ok. Could this be because the package.json specifies a specific version of bcrypt that needs to be loaded, and this version is one the only works against 2.28. Because the package.json and the package.lock are in git they get synced to the GS server and then when npm install bcrypt it automatically gets the version in the package.json and not the one that's compatiable with the current version of node?

jbrun001 commented 7 months ago

Disconnecting the tracking for package.json and package.json.lock from the roombooking folder which is synced with git locally in the terminal window of vscode git rm --cached package.json git rm --cached package-lock.json .gitignore added:
# package files - these can be re-created if needed on a new install with npm init # and then running the npm install (all the modules here) part of the readme.md package.json package.json.lock

This resulted in package.json and package.json.lock remaining on my local system. package-json.lock seems to still be in git (not ok) but package.json isn't on the server (thats ok) ok error is that the file name is wrong in git ignore changed to: # package files - these can be re-created if needed on a new install with npm init # and then running the npm install (all the modules here) part of the readme.md package.json package-lock.json

Now everything is as expected.

I have taken a local backup of the two files in case this causes anyone a problem.

jbrun001 commented 7 months ago

GS virtual myserver servers are not accessible at the moment: Looks like DNS lookup issue internally from doc.gold.ac.uk to myserver.doc.gold.ac.uk and also DNS lookup on doc.gold.ac.uk. The proxy server received an invalid response from an upstream server. The proxy server could not handle the request Reason: DNS lookup failure for: myserver.doc.gold.ac.uk Apache/2.4.41 (Ubuntu) Server at www.doc.gold.ac.uk Port 443

doc.gold.ac.uk failing tracert tracert doc.gold.ac.uk Tracing route to doc.gold.ac.uk [158.223.1.108] over a maximum of 30 hops: ... 4 8 ms 13 ms 9 ms 128.hiper04.sheff.dial.plus.net.uk [195.166.143.128] 5 7 ms 10 ms 10 ms peer7-et-3-0-1.telehouse.ukcore.bt.net [109.159.252.152] 6 8 ms 13 ms 5 ms linx-gw1.ja.net [195.66.224.15] 7 13 ms 7 ms 9 ms ae23.londtt-sbr1.ja.net [146.97.35.169] 8 11 ms 5 ms 6 ms ae28.londtw-sbr2.ja.net [146.97.33.62] 9 7 ms 7 ms 7 ms ae26.londtw-ban1.ja.net [146.97.35.218] 10 16 ms 6 ms 6 ms 146.97.141.21 11 * * * Request timed out. 12 * * * Request timed out. 13 * * * Request timed out.

Can't do any more until this is resolved. Might be maintenance affecting the servers. going in to create a new server might have the same issue.

jbrun001 commented 7 months ago

servers back up. I'll go in on Tuesday. The two failed upgrade attempts are taking up all the space in /tmp.. So will need to create a new virtual server. but I can't delete them because I'm not root and I can't sudo. drwx------ 8 root root 4096 Mar 23 12:34 ubuntu-release-upgrader-i3kp8mlm drwx------ 8 root root 4096 Mar 23 12:16 ubuntu-release-upgrader-qt5x732_

jbrun001 commented 7 months ago

After a lot of false starts I've got it running on Ubuntu18. I had to delete the machine and start over. I tried ubuntu20 but uni hasn't allocated enough space on that for even just the apt installs we need.

You will see that it doesn't format a the moment and you can't get past the login page. Formatting is simple - it's just that the style.css isn't being picked up by unix but it works on windows so that's just putting more of a path in. The form won't submit because of the security settings I think, so I will look at putting a switch in for these tomorrow.

Note that this is a copy of the database from planetscale. I can switch it to point at planetscale, but at the moment it's how it will be when we submit.

The issue was that we had a package.json in git. (not a bad thing). That contains the versions and dependencies, so when it was git pulled to the uni server and I tried to npm install, it tried to load the exact version of the packages in the package.json (which work in the dev environment) and not the ones that would work with ubuntu18. The process of trying to fix filled up the server. Solution was.

This means that the uni server might not be using exactly the same packages as we use when we're developing, except for tinymce where the actual version is specified in the npm install

jbrun001 commented 7 months ago

Uni package.json for reference "dependencies": {
"bcrypt": "^5.1.1",
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"dotenv": "^16.4.5", "ejs": "^3.1.9", "express": "^4.19.2", "express-session": "^1.18.0", "morgan": "^1.10.0", "multer": "^1.4.5-lts.1", "mysql2": "^3.9.3", "path": "^0.12.7", "qrcode": "^1.5.3", "sanitize-html": "^2.13.0", "speakeasy": "^2.0.0", "tinymce": "^6.8.3"