[英]Run PHP script after Azure Web app deployment
I am having an Azure app Service and I want to upload/deploy an.php file to it an run it right after the upload.我有一个 Azure 应用服务,我想上传/部署一个 .php 文件到它并在上传后立即运行它。
I managed to upload it via curl and also start a post deployment script.我设法通过 curl 上传它,并启动了一个部署后脚本。 Unfortunately I can not use the command "php..." in it because I get an error like: "/opt/Kudu/Scripts/starter.sh: line 2: exec: php: not found\n" in the logs.
不幸的是,我无法在其中使用命令“php ...”,因为我在日志中收到如下错误:“/opt/Kudu/Scripts/starter.sh: line 2: exec: php: not found\n”。 The same occurs if I use the "/api/command" endpoint with the same command.
如果我将“/api/command”端点与相同的命令一起使用,也会发生同样的情况。 I get the same kind of error in the response.
我在响应中得到了同样的错误。
It seems like the php executable is not known in that environment.在该环境中似乎不知道 php 可执行文件。 Is there any way to run a php script via the command API or in a post deployment script?
有没有办法通过命令 API 或在部署后脚本中运行 php 脚本?
EDIT for further clarification: I need curl because I want to run it automatically with a deployer which generates a php file which then does our specific deployment tasks (generating folders, symlinks and so on).编辑以进一步澄清:我需要 curl 因为我想使用生成 php 文件的部署程序自动运行它,然后执行我们的特定部署任务(生成文件夹、符号链接等)。 So after I deploy that php file on the App service I need to start it.
因此,在我在 App 服务上部署 php 文件后,我需要启动它。 So far curl was the only opportunity I found which doesn't need a user interaction if done correctly.
到目前为止,curl 是我发现的唯一一个如果操作正确则不需要用户交互的机会。 With right after the upload I mean after using one of the 2 SCM/Kudu apis which are "/api/zip/" or "api/zipdeploy/"
在上传之后,我的意思是在使用“/api/zip/”或“api/zipdeploy/”这两个 SCM/Kudu api 之一之后
Thanks in advance提前致谢
You can use WebJob for running the scripts in Azure App Service Instance without any user interactions or which acts as background tasks.您可以使用 WebJob 在 Azure 应用服务实例中运行脚本,无需任何用户交互或充当后台任务。
Azure WebJobs SDK is to simplify many programming tasks. Azure WebJobs SDK是为了简化许多编程任务。
The file types (scripts or programs) supported by Azure WebJobs SDK are: .cmd, .bat, .exe, .ps1, .sh .php , .py, .js, .jar The file types (scripts or programs) supported by Azure WebJobs SDK are: .cmd, .bat, .exe, .ps1, .sh .php , .py, .js, .jar
Just tweak your php script to have a loop and add a sleep of a few minutes between runs of your code.只需调整您的 php 脚本以进行循环并在代码运行之间添加几分钟的睡眠。
The continuous WebJob will run on all of your instances and even if something fails it will be brought back up.连续的 WebJob 将在您的所有实例上运行,即使出现故障,它也会重新启动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.