Lars
Lars

Reputation: 340

Deploying a basic Symfony app using Magallanes

Working on a simple Symfony application to demonstrate a continuous delivery pipeline. However, I can't get my deployment done using Magallanes. After deployment is finished, I need to manually run bin/console cache:clear --env=prod --no-debug every time. I have the following environment configuration:

#production
deployment:
  user: root
  from: ./
  to: /var/www/foo/
  excludes:
  strategy: rsync
releases:
  enabled: false
  max: 2
  symlink: current
  directory: releases
hosts:
  - foo
tasks:
  pre-deploy:
  on-deploy:
  post-release:
  post-deploy:
    - composer/install
    - general/manually:
      - HTTPDUSER=`ps axo user,comm | grep -E \'[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx\' | grep -v root | head -1 | cut -d\  -f1`
    - general/manually:
      - setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
    - general/manually:
      - setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
    - general/manually:
      - chmod +x bin/console
    - general/manually:
      - bin/console cache:clear --env=prod --no-debug

As you can see, a lot of manual tasks to get the permissions right. The error I receive when I visit my page is as followed:

PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/omnia/var/logs/prod.log" could not be opened: failed to open stream: Permission denied'

I was hoping that my tasks would fix this permission issue, in particular the last one, where I call cache:clear.

What to do?

Upvotes: 0

Views: 368

Answers (1)

goto
goto

Reputation: 8162

I don't know magallanes.
At the end of your script, you could set the right of www-data to the app/logs/* and app/cache. like

chmod www-data -r app/logs app/cache

If you prefer to use the commandline you have to use --no-warmup for symfony to not create anything. It will not solve the problem of the log though

php app/console cache:clear --env=prod --no-warmup --env=prod

Upvotes: 1

Related Questions