Understanding google cloud app engine and pub/sub to datastore


I am new to google cloud platform and particle community. Probably there is plenty similar topics but I can’t find any which fully answer my questions.

My goal is to collect published events from particle electron and store it in google cloud datastore. I made python program which subscribe from pub/sub and put in into datastore. I can run it locally on my computer and it works, but I want to run this program in google cloud shell that it could work even if my computer is off.

I clone my program to google cloud shell and it is working there, but when I close shell, my program also is closed which is understandable. I think I should use “gcloud app deploy” but I don’t want to try it before I fully understand it. Could somebody tell me what should I do to run my python program? Should I create something like app.yaml? How can I delete my program from app engine? On google cloud website there is plenty of information and i think i get lost.

Thanks for your help

This tutorial shows how to do both local and cloud-based saving of published data to a Google cloud datastore. It uses node.js, but the concepts for doing it in other languages are pretty similar.

1 Like

Thank you for your answer.

I prepared app.yaml:

runtime: python
env: flex
entrypoint: python Oratio.py

  python_version: 3

  instances: 1

but when I try to run gcloud app deploy I see error:
from google.cloud import pubsub
ModuleNotFoundError: No module named ‘google’.

When I input : “pip show google-cloud” I see version and even libraries

Name: google-cloud
Version: 0.32.0
Location: /usr/local/lib/python2.7/dist-packages
Requires: google-cloud-logging, google-cloud-error-reporting, google-cloud-dns, google-cloud-vision, google-cloud-core, google-cloud-firestore, google-cloud-language, google-cloud-container, goo
gle-cloud-monitoring, google-cloud-bigquery, google-cloud-storage, google-cloud-datastore, google-cloud-trace, google-cloud-speech, google-cloud-translate, google-cloud-bigquery-datatransfer, go
ogle-cloud-spanner, google-cloud-resource-manager, google-cloud-bigtable, google-cloud-videointelligence, google-api-core, google-cloud-runtimeconfig, google-cloud-pubsub

Do you know what is the problem?