简体   繁体   English

部署到 GAE 标准环境后如何自动启动 PHP Worker

[英]How to auto start PHP worker after deployment to GAE standard environment

In my app.yaml file I have the below config after going throw the document on https://cloud.google.com/appengine/docs/standard/php7/runtime#application_startup在我的 app.yaml 文件中,我在https://cloud.google.com/appengine/docs/standard/php7/runtime#application_startup上抛出文档后有以下配置

service: xxxx-xxxx

runtime: php72
entrypoint: php test.php

instance_class: F2
automatic_scaling:
  min_instances: 1
  max_instances: 2

env_variables:
  TEST: "xxxxx"

Directory structure目录结构

- test.php
- app.yaml

Problem: PHP script doesn't run after deployment but only runs when I hit the .appspot.com URL given.问题:PHP 脚本在部署后不运行,但仅在我点击给定的 .appspot.com URL 时运行。

What I want is to auto start the script after deployment.我想要的是在部署后自动启动脚本。

Thanks .谢谢 。

If you want your code to be autorun when you deploy your application you need to specify a minimum amount of instances to be run during the deploy, otherwise App Engine will wait until a request it's made to the URL to start an instance.如果您希望在部署应用程序时自动运行代码,则需要指定在部署期间运行的最少实例数量,否则 App Engine 将等到它向 URL 发出请求以启动实例。

What you need to do is to write your code outside of any route in your main and then implement automatic scaling in your app.yaml您需要做的是在 main 中的任何路由之外编写代码,然后在 app.yaml 中实现自动缩放

Here you have an example of my application taken form the Hello_World sample :这里有一个来自Hello_World 示例的应用程序示例

index.php索引.php

<?php
echo "hello world!";
syslog(LOG_INFO, 'Authorized access');

  // Handle your warmup logic for your app.
  switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
    case '/_ah/warmup':
      echo "Warmup successful";
      syslog(LOG_INFO, 'Authorized Warmup');
      break;
    // Other handlers
    // ...
  }
?>

app.yaml应用程序.yaml

runtime: php72

inbound_services:
- warmup

automatic_scaling:

    min_idle_instances: 2
    min_instances: 2

The number of instances will be equal to the number of times that you want your application to be run at the deployment.实例数将等于您希望应用程序在部署时运行的次数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP:在GAE标准环境中启用Ioncube加载程序扩展 - PHP : enable Ioncube loader extension in GAE standard environment 从 GAE php74 标准环境中的日志中删除“child said into stdout/stderr”前缀 - Removing "child said into stdout/stderr" prefix from logs in GAE php74 standard environment PHP守护进程/工作者环境 - PHP Daemon/worker environment 如何在Flex环境和PHP运行时中使用GAE处理CORS(或任何标头)? - How to handle CORS (or whatever headers) with GAE in flex environment and PHP runtime? 自动部署PHP应用程序 - Auto deployment of PHP applications 部署后如何在 Google App Engine Standard 上运行 Laravel 迁移 - How to run Laravel migrations on Google App Engine Standard after Deployment 如何确保 supervisord worker (php) 在 GAE flex env 上运行良好? - How to make sure supervisord worker (php) is running fine on GAE flex env? 有关PHP分段+部署环境的建议 - recommendations on PHP staging + deployment environment Azure Wordpress PHP Worker Role Terminates soon after start when following the azure sdk for php wordpress scaffold - Azure Wordpress PHP Worker Role Terminates soon after start when following the azure sdk for php wordpress scaffold PHP + MySQL:注册后如何自动登录 - PHP + MySQL: How to auto login after registration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM