Skip to content

Commit

Permalink
Merge pull request #226 from cashpipeplusplus/master
Browse files Browse the repository at this point in the history
docs: Add instructions for Google App Engine deployment
  • Loading branch information
afrokick authored Nov 24, 2020
2 parents 86ba5ba + 5f18c06 commit cbc7cbf
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,67 @@ This will start a peerjs server on port 9000 exposed on port 9000 with key `peer
Open your browser with http://localhost:9000/myapp It should returns JSON with name, description and website fields. http://localhost:9000/myapp/peerjs/id - should returns a random string (random client id)
## Running in Google App Engine
Google App Engine will create an HTTPS certificate for you automatically,
making this by far the easiest way to deploy PeerJS in the Google Cloud
Platform.
1. Create a `package.json` file for GAE to read:
```sh
echo "{}" > package.json
npm install express@latest peer@latest
```
2. Create an `app.yaml` file to configure the GAE application.
```yaml
runtime: nodejs
# Flex environment required for WebSocket support, which is required for PeerJS.
env: flex
# Limit resources to one instance, one CPU, very little memory or disk.
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 0.5
```
3. Create `server.js` (which node will run by default for the `start` script):
```js
const express = require('express');
const { ExpressPeerServer } = require('peer');
const app = express();
app.enable('trust proxy');
const PORT = process.env.PORT || 9000;
const server = app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
const peerServer = ExpressPeerServer(server, {
path: '/'
});
app.use('/', peerServer);
module.exports = app;
```
4. Deploy to an existing GAE project (assuming you are already logged in via
`gcloud`), replacing `YOUR-PROJECT-ID-HERE` with your particular project ID:
```sh
gcloud app deploy --project=YOUR-PROJECT-ID-HERE --promote --quiet app.yaml
```
## Privacy
See [PRIVACY.md](https://github.com/peers/peerjs-server/blob/master/PRIVACY.md)
Expand Down

0 comments on commit cbc7cbf

Please sign in to comment.