2

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
1

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

dear Adam thanks. before you answer my question i do same your answer and service is running and execute my command. in my command , execute a ffmpeg command (for convert video) but now my ffmpeg command not execute ?! i don't now why this happen in the even that running without a service ?!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.