Leo*_*nel 13 php cron worker background-process appfog
我搜索,搜索和搜索,但没有找到任何资源.
有没有什么办法来运行一个工人在一个AppFog的PHP应用程序?
我只根据这些语言的框架找到了运行Ruby,Node.js和Python worker的指令.
Leo*_*nel 30
经过大量的修修补补,我找到了办法!
在您的PHP脚本中,您应该将超时限制设置为0,并且具有无限循环,如下所示:
<?php
set_time_limit(0);
while (true) {
print "blah\n";
sleep(120);
}
Run Code Online (Sandbox Code Playgroud)
此代码每2分钟打印一次"blah".
要将其部署到AppFog,您必须使用afconsole命令.这里最重要的事情就是没有当它问,如果这是一个PHP应用程序.
af push 在目录上php index.php您为应用程序主文件指定的名称.这一切都显示如下:
D:\Users\Leonel\dev\app>af push
Would you like to deploy from the current directory? [Yn]:
Application Name: APP
Detected a PHP Application, is this correct? [Yn]: n
[...]
6: Standalone
[...]
Select Application Type: 6
Selected Standalone Application
[...]
5: php
[...]
Select Runtime: 5
Selected php
Start Command: php index.php
1: AWS US East - Virginia
[...]
Select Infrastructure: 1
Application Deployed URL [None]:
Memory reservation (128M, 256M, 512M, 1G, 2G) [128M]:
How many instances? [1]:
Bind existing services to 'APP'? [yN]:
Create services to bind to 'APP'? [yN]:
Would you like to save this configuration? [yN]:
Creating Application: OK
Uploading Application:
Checking for available resources: OK
Packing application: OK
Uploading (0K): OK
Push Status: OK
Staging Application 'APP': OK
Starting Application 'APP': OK
D:\Users\Leonel\dev\APP>af logs APP
====> /logs/stdout.log <====
blah
blah
Run Code Online (Sandbox Code Playgroud)
curl到您的其他应用程序.只需确保它位于相同的可用区域.af logs APP 将为您提供工作人员的输出,以便您可以调试并检查一切是否正常.就是这样,希望它有所帮助.