diff --git a/server/README.md b/server/README.md index 3aed801..aa38053 100644 --- a/server/README.md +++ b/server/README.md @@ -19,12 +19,19 @@ server folder in the Ghost Writer git repository. (Ex: `sudo ln -s ~/Ghost-Writer-Online/server /server`) 7. Create a symlink named `ghost-writer.service` in `/etc/systemd/system` pointing to the service file in the `server` folder of the Ghost Writer Online -repository. (Ex: `sudo ln -s /etc/systemd/system/ghost-writer.service /server/ghost-writer.service`) -8. Start the websocket server with `sudo systemctl start ghost-writer`. -9. Make sure the server is started by running `systemctl status ghost-writer` +repository. (Ex: `sudo ln -s /server/ghost-writer.service /etc/systemd/system/ghost-writer.service`) +8. Run `whereis node` and copy the absolute file path of the output +9. Edit the `ghost-writer.service` file to replace change the +`ExecStart=node dist/main.js` to replace `node` with the file path you copied +from the previous step +10. Reload the systemd daemon with `sudo systemd daemon-reload` to make the +changes to the service file take effect. +11. Start the websocket server with `sudo systemctl start ghost-writer` +12. Make sure the server is started by running `systemctl status ghost-writer` -* To restart the server, run `sudo systemctl restart ghost-writer`. -* To stop the server, run `sudo systemctl stop ghost-writer`. +* To start the server, run `sudo sustemctl start ghost-writer` +* To restart the server, run `sudo systemctl restart ghost-writer` +* To stop the server, run `sudo systemctl stop ghost-writer` * To access the server logs, run `sudo journalctl -u ghost-writer` diff --git a/server/src/events/DeleteGame.ts b/server/src/events/DeleteGame.ts index 00b1624..df55005 100644 --- a/server/src/events/DeleteGame.ts +++ b/server/src/events/DeleteGame.ts @@ -6,7 +6,7 @@ export default (io: Server, socket: Socket, data: DeleteGame) => { // Ensure game exists if (!games[data.game_code]) { - log.debug(`Can't delete game that doesn't exist: ${data.game_code}`); + log.debug(`Can't find game with code: ${data.game_code}`); socket.emit(`GameDeleted`, { status: 404, message: `Game with code ${data.game_code} could not be found`, @@ -21,7 +21,7 @@ export default (io: Server, socket: Socket, data: DeleteGame) => { let player = game.players.find(x => x.isHost); if (player != null && player.socket !== socket) { - game.log.warn(`${player.name} attempted to delete game.`); + game.log.warn(`${player.name} attempted to delete game`); socket.emit(`GameDeleted`, { status: 403, message: `Not allowed to delete a game that you are not the host of.`, @@ -31,7 +31,7 @@ export default (io: Server, socket: Socket, data: DeleteGame) => { }; // Delete game - game.log.debug(`Game deleted.`) + game.log.info(`Game deleted`) delete games[data.game_code]; io.to(game.id).emit(`GameDeleted`, { status: 200, diff --git a/server/src/main.ts b/server/src/main.ts index cb5cdc2..533cdb2 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -49,6 +49,7 @@ if (Validate.config(conf)) { log.info(`Found ${hibernatedGames.length} hibernated games`); process.on(`uncaughtException`, processExit); process.on(`SIGINT`, processExit); + process.on(`SIGTERM`, processExit); }; startWebsocket(conf);