简体   繁体   中英

Run code on Python Flask AppEngine startup in GCP

I need to have a TCP client that listens to messages constantly (and publish pub sub events for each message)

Since there is no Kafka in GCP, I'm trying to do it using my flask service (which runs using AppEngine in GCP).

I'm planning on setting the app.yaml as:

manual_scaling:
  instances: 1

But I can't figure out how to trigger code on the flask app startup.

I've tried running code in the main.py and also tried to manipulate the main function in it - but it obviously doesn't work as AppEngine doesn't run it.

Do you have any idea how can I init the listener on the Flask' app startup?

(Or any other offer regarding how should I implement a tcp client that sends pubsub events, or inserting to Big Query?)

I eventually went for implementing a Kafka connector myself and using Kafka.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM