1

我已经将 Heroku 的调度程序配置为运行 Symfony 2 命令:

bash app/console myapp:send:confirmations --verbose

并将其设置为每 10 分钟运行一次。

但是,在日志中我看到了这些消息:

2015-09-10T13:01:25.313711+00:00 heroku[api]: Starting process with command `bash app/console myapp:send:confirmations` by scheduler@addons.heroku.com
2015-09-10T13:01:44.151426+00:00 heroku[scheduler.7629]: Starting process with command `bash app/console myapp:send:confirmations --verbose`
2015-09-10T13:01:44.811500+00:00 heroku[scheduler.7629]: State changed from starting to up
2015-09-10T13:01:45.565021+00:00 app[scheduler.7629]: app/console: line 2: ?php: No such file or directory
2015-09-10T13:01:45.565093+00:00 app[scheduler.7629]: app/console: line 19: unexpected EOF while looking for matching `''
2015-09-10T13:01:45.565096+00:00 app[scheduler.7629]: app/console: line 28: syntax error: unexpected end of file
2015-09-10T13:01:46.291606+00:00 heroku[scheduler.7629]: State changed from up to complete
2015-09-10T13:01:46.278800+00:00 heroku[scheduler.7629]: Process exited with status 2

这些是让我感到困惑的三个相关因素:

2015-09-10T13:01:45.565021+00:00 app[scheduler.7629]: app/console: line 2: ?php: No such file or directory
2015-09-10T13:01:45.565093+00:00 app[scheduler.7629]: app/console: line 19: unexpected EOF while looking for matching `''
2015-09-10T13:01:45.565096+00:00 app[scheduler.7629]: app/console: line 28: syntax error: unexpected end of file

我有点困惑:文件app/console似乎不存在,但随后脚本遇到意外的 EOF(但文件不存在 oO),然后文件意外结束(这与消息 immediatley 不是一回事前?

我究竟做错了什么?

4

1 回答 1

1

使用php而不是bash启动控制台:

php app/console myapp:send:confirmations --verbose

我在 Ubuntu 15.04 上有相同的行为(崩溃):

$ bash app/console
app/console: line 2: ?php: No such file or directory
app/console: line 18: unexpected EOF while looking for matching `''
app/console: line 23: syntax error: unexpected end of file
$ php app/console -v
Symfony version 2.7.4 - app/prod
...

似乎从一开始就忽略了shebang ,并且没有调用PHP解释器:app/console

#!/usr/bin/env php
<?php
....

以下是Aaron Copley的解释:

不可执行

使用绝对或相对路径运行二进制文件

因此,如果您将文件标记为可执行文件并使用相对路径启动脚本,则会调用 PHP 解释器:

$ chmod +x app/console
$ ./app/console -v
Symfony version 2.7.4 - app/prod
于 2015-09-10T13:29:14.200 回答