2
votes

I'm trying to deploy my app to Google Clouds App Engine. It works perfectly as a local instance, but as soon as I upload it to gcloud, it stops working as intended.

I'm creating a bot for discord. Through it, I access discord and youtubes API. Connecting to these seems to work, as the bot comes online after publishing. However, it seems that the music-playing functionality stops working when its running on gcloud. All other functions work as intended. Which is why I'm suspecting that something has gone wrong with some of the packages. Probably related to music or sound.

Question: Is there a way to verify that my node packages have been installed correctly through the cloud Console or cmd? Or better yet, re-install them.

I have looked at Deploy and run App Engine.

I publish using the cmd-tools and by running: gcloud app deploy

app.yaml:

runtime: nodejs
env: flex
manual_scaling:
  instances: 1

package.json:

{
  "name": "yup",
  "version": "1.0.5",
  "description": "bot",
  "main": "app.js",
  "private": true,
  "engines": {
    "node": ">=8.11.3"
  },
  "scripts": {
    "start": "node app.js",
    "deploy": "gcloud app deploy",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Joel",
  "license": "ISC",
  "dependencies": {
    "@types/request": "^2.48.1",
    "discord.js": "^11.4.2",
    "express": "^4.16.4",
    "ffmpeg-binaries": "^4.0.0",
    "fs": "0.0.1-security",
    "get-youtube-id": "^1.0.1",
    "opusscript": "0.0.6",
    "request": "^2.88.0",
    "youtube-info": "^1.3.2",
    "ytdl-core": "^0.29.1",
    "ytdl-getinfo": "^1.1.0"
  },
  "devDependencies": {
    "typescript": "^3.3.3333"
  }
}

On further inspection, i can see this in the install-logs:

Step #1: npm WARN [email protected] requires a peer of bufferutil@^3.0.3 but none is installed. You must install peer dependencies yourself.
Step #1: npm WARN [email protected] requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
Step #1: npm WARN [email protected] requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
Step #1: npm WARN [email protected] requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
Step #1: npm WARN [email protected] requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
Step #1: npm WARN [email protected] requires a peer of uws@^9.14.0 but none is installed. You must install peer dependencies yourself.
2

2 Answers

1
votes

To check if dependencies of App Engine app are installed correctly from the Google Cloud Console:

  1. Inspect logs on the Stackdriver Logging > Logs (Logs Viewer) page.
  2. Filter logs:
    • by resource, selecting from the drop down menu: Cloud Build,
    • by text search, to search for package.json or specify package, for example ffmpeg-binaries,
    • by date,

It is also possible to get App Engine builds log from Cloud Shell Environment:

  1. Get ID of the build: $ cloud builds list
  2. List complete build log: $ gcloud builds log [build-ID]

In the logs you should see: successfully installed [package name-version]

To reinstall dependencies, you need to deploy new version of your app. In case of the problem with already cached package, try --no-cache flag, mentioned in the documentation.


1
votes

This was actually caused by multiple things:

If you find yourself in a similar situation where neither the compiler or runtime is complaining and it works in your dev-environment but not in production. Then I would highly recommend looking through any external dependencies.

Cause

FFMPEG-binaries did install from my package-json. BUT - it didn't work until I installed it globally using the -g flag.

Also, in this specific situation I had to verify the integrity of my overall FFMPEG installation, which for some reason, was not working.

You should be able to run ffmpeg in your console and get some basic information regarding usage. If that works, you should be good to go!

Now it works (FFMPEG was the cause)!

I also switched from App engine to VM instance as I could not find any way to install system dependencies on App Engine. Using a VM instance, I could manually install the packages through SSH.

Unrelated: it turns out that peer dependencies are optional.