Pro*_*OXO 3 python python-3.x google-cloud-platform google-cloud-functions
这就是我目前正在做的事情。这是不可取的,因为它会复制具有共享功能的相同 lib/ 文件夹:
\n\n/project/\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 /cloudfunctions/\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 /functionA/\n \xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 main.py\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 /lib/\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 /functionB/\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 main.py\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 /lib/\nRun Code Online (Sandbox Code Playgroud)\n\n我该如何组织或部署功能,才能让项目结构更像这样?
\n\n/project/\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 /cloudfunctions/\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 /functionA/\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.py\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 /functionB/\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.py\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 /lib/\nRun Code Online (Sandbox Code Playgroud)\n\n为了澄清更多,我想知道为什么没有标志--include-dependencies,gcloud functions deploy并且我想知道最好的做法是在第二个文件夹结构中包含共享库。
现在这是我的 janky hackdeploy.sh
rm -rf lib\ncp -r ../lib ./lib\ngcloud functions deploy...\nRun Code Online (Sandbox Code Playgroud)\n
您可以在一个目录中拥有多个函数。常见的结构如下:
\n\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 common\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 module1.py\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 module2.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 main.py\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 requirements.txt\nRun Code Online (Sandbox Code Playgroud)\n\n其中main.py包含两个函数:
from common import module1, module2\n\ndef cloudfunction1(request):\n ...\n\ndef cloudfunction2(request):\n ...\nRun Code Online (Sandbox Code Playgroud)\n\n您可以直接按名称部署这些函数:
\n\n$ gcloud beta functions deploy cloudfunction1 --runtime python37 --trigger-http\n$ gcloud beta functions deploy cloudfunction2 --runtime python37 --trigger-http\nRun Code Online (Sandbox Code Playgroud)\n\n或者通过入口点:
\n\n$ gcloud beta functions deploy foo --runtime python37 --entry-point cloudfunction1 --trigger-http\n$ gcloud beta functions deploy bar --runtime python37 --entry-point cloudfunction2 --trigger-http\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1373 次 |
| 最近记录: |