diff --git a/Backend/deploy/project2-backend.service b/Backend/deploy/project2-backend.service index 7844e6e..72e0061 100644 --- a/Backend/deploy/project2-backend.service +++ b/Backend/deploy/project2-backend.service @@ -1,15 +1,14 @@ [Unit] Description=Project 2 GraphQL backend -After=network-online.target +After=network-online.target postgresql.service Wants=network-online.target -StartLimitIntervalSec=0 [Service] -Type=simple -WorkingDirectory=%h/T10-project-2 -ExecStart=/bin/bash -c 'source "$HOME/.nvm/nvm.sh" && exec node Backend/Server.ts' +User=project2 +WorkingDirectory=/srv/project2/app +ExecStart=/usr/bin/node --env-file=.env Backend/Server.ts Restart=always RestartSec=5 [Install] -WantedBy=default.target +WantedBy=multi-user.target diff --git a/README.md b/README.md index 0886ed7..989d3e9 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,27 @@ Our database has been filled with information from [SteamSpy](https://steamspy.c ## Backend -The Apollo GraphQL backend runs as a user-level system service on the VM on port 3001, and can be accessed using this link: [http://it2810-10.idi.ntnu.no:3001/](http://it2810-10.idi.ntnu.no:3001/). The instructions for setting up, starting, stopping, and restarting the backend with the VM are provided in a private document shared with all project members and administrators. You can run the backend localy by following the steps under [Setting up a local project](#setting-up-a-local-project) +The Apollo GraphQL backend runs on the VM on port 3001, and can be accessed using this link: [http://it2810-10.idi.ntnu.no:3001/](http://it2810-10.idi.ntnu.no:3001/). It runs as a system service (`project2-backend.service`) from a shared clone of this repository in `/srv/project2/app`, and it starts automatically when the VM boots. You can run the backend locally by following the steps under [Setting up a local project](#setting-up-a-local-project). + +### Backend guide on the VM (requires sudo permission) + +The full guide for starting, stopping, restarting, updating, and setting up the backend from scratch, including the database login details, is stored on the VM in a file that can only be read with sudo rights. Anyone with sudo access on the VM (group members and course administrators) can read it: + +1. Log in to the VM: + + ```sh + ssh @it2810-10.idi.ntnu.no + ``` + +2. Read the guide (you will be asked for your own sudo password): + + ```sh + sudo cat /srv/project2/BACKEND_HOWTO.md + ``` + + To scroll through it instead, use `sudo less /srv/project2/BACKEND_HOWTO.md` (press `q` to quit). + +Without sudo rights, the file cannot be opened. The same applies to the backend's env file, `/srv/project2/app/.env`. ## Setting up a local project