BLO9
Kotlin 등 개발 관련 포스팅합니다.
Node google cloud platform guide

Google Cloud Platform logo

nodejs-docs-samples.git

자연어처리 API를 사용해보려다가 한국어는 아직 지원이 안된다고 하길래 접기 아쉬워서 적어둡니다.

이곳에서 지원가능한 샘플들을 확인 할 수 있습니다. Google Cloud Platform products.

이곳에서 자세한 정보를 확인 할 수 있습니다. cloud.google.com/nodejs

목차

설정

기본설정

  1. Node.js (and NPM) 를 설치합니다.
  2. 프로젝트 생성

    붉은 밑줄이 Project-id입니다. 5번에서 사용.

  3. 예제 Repository clone

    git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git

  4. 예제로 이동

    cd nodejs-docs-samples

  5. GCLOUD_PROJECT 를 설정합니다.:

    2번에 밑줄친 id를 넣습니다.

    Linux: export GCLOUD_PROJECT=your-project-id Windows: set GCLOUD_PROJECT=your-project-id Windows (PowerShell): $env:GCLOUD_PROJECT=”your-project-id”

  6. 인증정보를 설정.

    Create local credentials by running the following command and following the oauth2 flow (read more about the command here):

     gcloud beta auth application-default login
    

    In non-Google Cloud environments, GCE instances created without the correct scopes, or local workstations where the gcloud beta auth application-default login command fails, use a service account by doing the following:

    • Go to API Manager -> Credentials
    • Click “New Credentials”, and create a service account or click here
    • Download the JSON for this service account, and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to the file containing the JSON credentials.

    API관리자 > 사용자 인증 정보 > 사용자 인증정보 만들기 > 서비스 계정 키

    인증정보 JSON을 다운 받은 뒤 접근하기 좋은 위치에 옮겨둡니다.

    인증정보 JSON 설정

    Linux:

    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json

    Windows:

    set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_file.json

    Windows (PowerShell):

    $env:GOOGLE_APPLICATION_CREDENTIALS=”/path/to/service_account_file.json”

    Note for code running on GCE, GAE, or other environments:

    On Google App Engine, the credentials should be found automatically.

    On Google Compute Engine, the credentials should be found automatically, but require that you create the instance with the correct scopes.

     gcloud compute instances create --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/compute.readonly" test-instance
    

    If you did not create the instance with the right scopes, you can still upload a JSON service account and set GOOGLE_APPLICATION_CREDENTIALS as described.

    Read more about Google Cloud Platform Authentication.

예제실행

  1. Change directory to one of the sample folders, e.g. bigquery:

    cd bigquery/

  2. Install the sample’s dependencies (see the sample’s README for details):

    npm install

  3. Run the sample:

    node sample_file.js [args]...

테스트실행

  1. 참조 [Contributing Guide][contrib].
  2. Set the TEST_BUCKET_NAME environment variable to the name of a test Google Cloud Storage bucket:

    Linux:

    export TEST_BUCKET_NAME=your-bucket-name

    Windows:

    set TEST_BUCKET_NAME=your-bucket-name

    Windows (PowerShell):

    $env:TEST_BUCKET_NAME=”your-bucket-name”

  3. In a terminal, start Redis:

    redis-server

  4. In another terminal, start memcached:

    memcached

  5. In another terminal, run the tests from the root of the project:

    npm test