|
| 1 | +# Overview |
| 2 | + |
| 3 | +This sample uses the `@google-cloud/synthetics-sdk-broken-links` to create a Google Cloud Function that can be used with Google Cloud Monitoring Synthetics. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +``` |
| 8 | +# from root of repo, build all packages |
| 9 | +npm install |
| 10 | +``` |
| 11 | + |
| 12 | +Update the `options` variable in the `index.js` to the desired `origin_uri` along with any other (optional) fields. |
| 13 | + |
| 14 | +## Running |
| 15 | + |
| 16 | +The following command runs this sample locally |
| 17 | +``` |
| 18 | +npx functions-framework --target=BrokenLinkChecker |
| 19 | +``` |
| 20 | + |
| 21 | +The following command deploys this sample to gcp as a cloud function. |
| 22 | +``` |
| 23 | +gcloud functions deploy broken-links-http --gen2 --runtime=nodejs18 --region=us-east4 --source=. --entry-point=BrokenLinkChecker --trigger-http --timeout=60 --memory=2048M |
| 24 | +``` |
| 25 | + |
| 26 | +## Running Local Synthetics SDK Changes |
| 27 | + |
| 28 | +Use the following instructions to run the version of the synthetics-sdk-broken-links package that has local changes. *The instructions should start from the root directory for the `synthetics-sdk` workspace.* |
| 29 | + |
| 30 | +1. Pack "@google-cloud/synthetics-sdk-api" into tar file, output to synthetics-sdk-broken-links |
| 31 | +``` |
| 32 | +npm pack --workspace="@google-cloud/synthetics-sdk-api" --pack-destination=packages/synthetics-sdk-broken-links/ |
| 33 | +cd packages/synthetics-sdk-broken-links/ |
| 34 | +``` |
| 35 | + |
| 36 | +2. Open package.json, update synthetics-sdk-broken-links dependency for "@google-cloud/synthetics-sdk-api" to use tar file. |
| 37 | + |
| 38 | +``` |
| 39 | +"dependencies": { |
| 40 | + ... |
| 41 | + "@google-cloud/synthetics-sdk-api": "google-cloud-synthetics-sdk-api-0.5.0.tgz" |
| 42 | + ... |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +3. Go back to root directory of synthetics-sdk |
| 47 | +``` |
| 48 | +cd ../.. |
| 49 | +``` |
| 50 | + |
| 51 | +4. Pack all workspace packages into tar files, output to samples/broken-links-ok |
| 52 | +``` |
| 53 | +npm pack --workspaces --pack-destination=samples/broken-links-ok/ |
| 54 | +cd samples/broken-links-ok/ |
| 55 | +``` |
| 56 | + |
| 57 | +5. Open package.json, update broken-links-ok dependency for "@google-cloud/synthetics-sdk-broken-links" and "@google-cloud/synthetics-sdk-api" to use tar file. |
| 58 | +``` |
| 59 | +"dependencies": { |
| 60 | + ... |
| 61 | + "@google-cloud/synthetics-sdk-broken-links": "google-cloud-synthetics-sdk-broken-links-0.1.2.tgz", |
| 62 | + "@google-cloud/synthetics-sdk-api": "google-cloud-synthetics-sdk-api-0.5.0.tgz" |
| 63 | + ... |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +Proceed back to steps in [RUNNING](#Running) |
0 commit comments