在ubuntu中将symfony命令作为服务运行

时间:2014-08-03 13:01:18

标签: php linux symfony service

我有一个在终端正常运行的命令:

 php -f /home/roshd-user/Symfony/app/console video:convert

我希望在我的服务器中将此命令作为服务运行。在/ etc / init /中创建一个vconvertor.conf 。

此服务正常运行(启动和停止)但不执行我的命令?

我没有服务的命令运行良好并返回我的结果但是当它用于服务时不执行?!

vconvertor.conf包含以下代码:

#info
description "Video Convertor PHP Worker"
author      "Netroshd"

# Events
start on startup
stop on shutdown

# Automatically respawn
respawn
respawn limit 20 5

# Run the script!
# Note, in this example, if your PHP script returns
# the string "ERROR", the daemon will stop itself.
script
    [ $( exec php -f /home/roshd-user/Symfony/app/console video:convert
 ) = 'ERROR' ] && ( stop; exit 1; )
end script

1 个答案:

答案 0 :(得分:1)

我会在您的配置中将setuidsetgid声明为Apache用户组,即www-data 并使您的命令在prod Symfony环境中运行。

#info
description "Video Convertor PHP Worker"
author      "Netroshd"

# Events
start on startup
stop on shutdown

# Automatically respawn
respawn
respawn limit 20 5

# Run as the www-data user and group (same as Apache is under in Ubuntu)
setuid www-data
setgid www-data

# Run the script!
exec php /home/roshd-user/Symfony/app/console video:convert -e prod --no-debug -q

如果您仍然遇到问题,可能需要在Composer中安装"wrep/daemonizable-command"并使视频转换命令扩展Wrep\Daemonizable\Command\EndlessContainerAwareCommand。该库还提供an example of how to use it