Questions tagged with Game Server Hosting & Backends

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

  • 1
  • 2
  • 12 / page

Installing NodeJS + NPM in a Build fleet (not Realtime Script)

Hi all, I have an existing game using Unity for the frontend, but NodeJS for the backend. I can't port my backend over to Unity any time soon, so I've managed to get it working on GameLift in its current state. But there's room for improvement. First I'll explain how I've set it up: 1. Used an unofficial AWS GameLift NodeJS Server SDK ( (Apologies if it's against the rules to link to unofficial SDKs here - I'm happy to redact this, just thought it would add some context) 2. Prepackaged a NodeJS v16 binary into the build zip that I upload to GameLift 3. Prepackaged my node_modules folders (all of the dependencies) in the build zip 4. My startup script ( sets up the NodeJS binary and executes Node within the calling process Here's what my looks like: ``` #!/bin/bash echo "Running 'node src/game-lift/GameLift.js' from Process ID $$" echo "Setting up node" PWD=`pwd` PATH=$PATH:$PWD/deps/node-v16.16.0-linux-x64/bin node --version echo "Executing 'node dist/src/game-lift/GameLift.js'" exec node dist/src/game-lift/GameLift.js ``` `exec` ensures that NodeJS is run within the same process as the calling script, so that GameLift can monitor the process for irregularities (I assume). I launch the Fleet with the following command: ``` aws gamelift create-fleet \ --name REDACTED-fleet-name \ --build-id build-REDACTED \ --ec2-instance-type m5.large \ --ec2-inbound-permissions 'FromPort=1234,ToPort=1234,IpRange=,Protocol=TCP' \ --fleet-type ON_DEMAND \ --runtime-configuration 'ServerProcesses=[{LaunchPath=/local/game/,ConcurrentExecutions=1}],MaxConcurrentGameSessionActivations=1,GameSessionActivationTimeoutSeconds=600' ``` Two concerns about this approach: 1. Prepackaging NodeJS is not cool / sustainable. I'd rather install it in, using some platform independent method. 2. Running `exec` to ensure Node doesn't break out into another process seems hacky and potentially problematic. I would rather set the launch path to simply `node` and add the script as a parameter. For example: ``` --runtime-configuration 'ServerProcesses=[{LaunchPath=node,Parameters=dist/src/game-lift/GameLift.js,ConcurrentExecutions=1}],MaxConcurrentGameSessionActivations=1,GameSessionActivationTimeoutSeconds=600' ``` Maybe I'm overthinking item #2 - it might not be a problem as-is But as for #1, I would love to take advantage of that script. Previously I was installing NodeJs in via N ( But I found that Node was not available in I even SSH'd in and it seemed like NodeJS was not installed. **Question #1**: Am I misunderstanding what does? Should I be able to use it to install NodeJS (or any dependency) and later on use that dependency in my launch script? **Question #2**: Anyone got any tips on how to install Node in GameLift reliably? Yum? N? Nvm? etc. I know NodeJS isn't officially supported, but I'm hoping to get just a general idea of what should and should not be possible in GameLift. Any help would be greatly appreciated.
profile picture
asked 5 months ago
  • 1
  • 2
  • 12 / page