Reputation: 144
i have a command that run normally in terminal :
php -f /home/roshd-user/Symfony/app/console video:convert
i want run this command as service in my server. create a vconvertor.conf in /etc/init/ .
this service run(start and stop) normally but not execute my command ?!
my command without service is run well and return my result but when use it into a service not execute ?!
vconvertor.conf contain this codes :
#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
Upvotes: 2
Views: 2529
Reputation: 7818
I would declare setuid
and setgid
in your config as the Apache usergroup ie www-data
and make your command run in the prod
Symfony environment.
#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
If you still have issues, it might be worth installing the "wrep/daemonizable-command"
with Composer and making your video convert command extend the Wrep\Daemonizable\Command\EndlessContainerAwareCommand
. The library also provides an example of how to use it
Upvotes: 1