Roots Discourse

Deployment issues with php-fpm

Hi,

Firstly, thank you very much to anyone who is reading this, and anyone who has any answers.

I am trying to deploy to my production server, and having gone through every other step and succeeded my CLI is constantly stopping on:

TASK [deploy : Reload php-fpm]

I’t like the process is just pausing. I am using the most recent version of Ansible: ansible-2.0.0.2.

I have left it running for up to 2 hours and still on the same place. When I cancel the process I just get a summary of the upload, and no error message.

I am not sure if I need to install a package or something is out of date, hopefully this is the case, but whatever it is, it’s very annoying.

I am very new to using processes like this so sorry if there is an obvious answer.

Many thanks,

Mat

@mtd3sign I’m guessing you…

  • provisioned your server (ran server.yml) back before Trellis added php7
  • updated your Trellis to php7
  • tried a deploy (deploy.yml) before having rerun server.yml

The reload task is probably hanging because it may be trying to sudo service php7.0-fpm reload but there is no service named php7.0-fpm, at least not yet, not till you rerun server.yml to install php7.

Try running server.yml to install php7 then try your deploy again and let us know how it goes.

Thanks for the super quick reply @fullyint!

I ran server.yml this morning right before trying to deploy.

I haven’t managed to deploy at all just yet, so I’m wondering if it’s a setup error.

I have since run:

vagrant provision,
ansible-playbook server.yml -e env=production,
./deploy.sh production my xxx.com

From what I saw on the feedback PHP7 was installed when I ran vagrant provision.

TASK [php : Add PHP 7.0 PPA] ***************************************************
changed:[xxx.xx.xx.xxx]

TASK [php : Install PHP 7.0] ***************************************************
changed: [xxx.xx.xx.xxx] => (item=[u'php7.0-cli', u'php7.0-common', u'php7.0-curl', u'php7.0-dev', u'php7.0-fpm', u'php7.0-gd', u'php7.0-mcrypt', u'php7.0-mysql', u'php7.0-opcache'])`
  
TASK [php : Start php7.0-fpm service] ***
ok: [xxx.xx.xx.xxx]

TASK [php : PHP configuration file] ***
changed: [xxx.xx.xx.xxx]

TASK [php : php-fpm configuration file] ***
changed: [xxx.xx.xx.xxx]

server.yml ran correctly.

Unfortunately I have the same issue, just stops on:

TASK [deploy : Reload php-fpm] ***

Couple things you can do to help debug:

  • SSH into your server as the web user and try running sudo service php7.0-fpm reload

If it prompts you for a password then that’s bad and it’s whats causing the “pause” during the deploy.

  • Check if a /etc/sudoers.d/web-services file exists and paste its contents

Thans for the reply @swalkinshaw.

I have accessed the console and the reload has worked with no errors, nor did it ask for a password.

I also checked if the web-services file exists and it does. here are the contents:

web ALL=(root) NOPASSWD: /usr/sbin/service hhvm * 
web ALL=(root) NOPASSWD: /usr/sbin/service php5-fpm * 

I’m going to try running server.yml again and then deploy should all go ok.

I have just had an error when running the server.yml command:

PLAY [WordPress Server - Install LEMP Stack with PHP 7.0 and MariaDB MySQL] ****

TASK [setup] *******************************************************************
fatal: [xxx.xx.xx.xx]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "sudo: a password is required\r\n", "msg": "MODULE FAILURE", "parsed": false}

Not sure if this has anything to do with it but I am currently having a couple of issues with SSH and my DO droplet and intermittently being denied remote access. I have had to destroy my droplet a couple of times and begin a new droplet.

@mtd3sign re: the error sudo: a password is required on the setup task for server.yml, I think I’ve seen that when I have sshd_permit_root_login: false and forget to add the --ask-become-pass to my ansible-playbook command.

If that applies to you, check out the Security docs which mentions how you’ll need to add the --ask-become-pass flag to your ansible-playbook command now that root login is disabled. So, try this:

ansible-playbook server.yml -e env=production --ask-become-pass

Or use -K (that’s a capital K) for short:

ansible-playbook server.yml -e env=production -K

Immediately after you initiate the command, it will ask you to type that password you created for the admin user (docs mention that the default is example_password). That way Ansible can use the password for any commands it must run as sudo.

@fullyint that worked perfectly, thank you.

However I am still having the process stop on:

[depoly: Reload php-fpm]

@swalkinshaw I have logged into the console and ran:

sudo service php7.0-fpm reload

which ran ok with no errors but the process is still stopping. Could there be another point in the process where I could be going wrong?

Once agin, many thanks for you help on this guys.

When you mentioned logging “into the console,” I wondered if perhaps you logged into Digital Ocean’s web GUI Console Access, perhaps as the root user, whereas we need to be sure the web user can perform the reload.

Just to confirm, when you run the following command from your local machine:

ssh web@xxx.xx.xx.xx "sudo service php7.0-fpm reload"

What is the output? Here’s mine:

 * Reloading PHP 7.0 FastCGI Process Manager php-fpm7.0
   ...done.

Could you also run the long-form deploy command in order to add the -vvvv flag:

ansible-playbook deploy.yml -e "site=example.com env=production" -vvvv

Does the verbose output show the web user, like below?

<xxx.xx.xx.xx> ESTABLISH SSH CONNECTION FOR USER: web

The web - reload ran fine, with the same output as yours.

I re-ran server.yml which ran correctly.

Then ran the deploy command you provided above and got:

<xxx.xx.xx.xxx> ESTABLISH SSH CONNECTION FOR USER: web

The process stalled again and the output was:

TASK [deploy : Reload php-fpm] ************************************************* task path: /../trellis/roles/deploy/hooks/finalize-after.yml:33 <xxx.xx.xx.xxx> ESTABLISH SSH CONNECTION FOR USER: web <xxx.xx.xx.xxx> SSH: EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=web -o ConnectTimeout=10 -o ControlPath=/Users/mathewthomas/.ansible/cp/ansible-ssh-%h-%p-%r -tt xxx.xx.xx.xxx '( umask 22 && mkdir -p "$( echo $HOME/.ansible/tmp/ansible-tmp-1454930273.05-137296709084917 )" && echo "$( echo $HOME/.ansible/tmp/ansible-tmp-1454930273.05-137296709084917 )" )' <xxx.xx.xx.xxx> PUT /var/folders/k3/btts93qn4b35hdcv_8wbs17r0000gn/T/tmpzt1z1t TO /home/web/.ansible/tmp/ansible-tmp-1454930273.05-137296709084917/command <xxx.xx.xx.xxx> SSH: EXEC sftp -b - -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=web -o ConnectTimeout=10 -o ControlPath=/Users/mathewthomas/.ansible/cp/ansible-ssh-%h-%p-%r '[xxx.xx.xx.xxx]' <xxx.xx.xx.xxx> ESTABLISH SSH CONNECTION FOR USER: web <xxx.xx.xx.xxx> SSH: EXEC ssh -C -vvv -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=web -o ConnectTimeout=10 -o ControlPath=/Users/mathewthomas/.ansible/cp/ansible-ssh-%h-%p-%r -tt xxx.xx.xx.xxx 'LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 /usr/bin/python /home/web/.ansible/tmp/ansible-tmp-1454930273.05-137296709084917/command; rm -rf "/home/web/.ansible/tmp/ansible-tmp-1454930273.05-137296709084917/" > /dev/null 2>&1'

Thanks for sharing the reload task output. Mine is the same, except it goes on to succeed. I’m rather uncertain what the problem is.

We could check if your installation needs an alternative formulation of the reload task, using Ansible ad hoc commands. You run these via your CLI to run a single task instead of an entire playbook.

An ad hoc command for the existing reload task would be this:

ansible "web:&staging" -m shell -a "sudo service php7.0-fpm reload" -u web

That will presumably hang for you, like the reload hangs during deploy.

You could see if this alternative succeeds (for some strange reason):

ansible "web:&staging" -m service -a "name=php7.0-fpm state=reloaded" -u web

I’d be curious whether a fresh new vanilla clone of Trellis (no customizations except domain name and IP) would succeed in reloading php during deploy. If so, that would implicate one of your customizations as the culprit. If not, then this seems to be a bit of a mysterious new problem :crystal_ball:.

Haha, I hope this doesn’t end up being too mysterious.

However I don’t actually have a staging server set up at the moment so I can only assume that I need to change that part of the code. I changed ansible "web:&staging" to ansible "web:" and got this code:

Mathews-MBP:trellis mathewthomas$ ansible "web:" -m service -a "name=php7.0-fpm state=reloaded" -u web xxx.xx.xx.xxx | SUCCESS => { "changed": true, "name": "php7.0-fpm", "state": "started" }

The first piece of code did hang, so I had to terminate the process.

I have tried to deploy after running that second code and get a GIT repo error saying that it’s invalid, weird. Haven’t seen that before ad probably an error on my part.

Also tried to re-run the server.yml playbook and got a error saying:

TASK [wordpress-setup : Create/assign database user to db and grant permissions] ***
fatal: [xxx.xx.xx.xxx]: FAILED! => {"failed": true, "msg": "ERROR! 'dict object' has no attribute u'postfiftythree.com'"}

postfiftythree.com being my url.

I should have written "web:&production" instead of "web:&staging". I was testing on staging and forgot to edit my command before pasting it here. It means "apply this command to all the hosts who are in both the web and production groups.

As for the 'dict object' has no attribute error, you may need to change example.com to postfiftythree.com in group_vars/production/vault.yml. I’m surprised it hasn’t thrown that error before when you ran server.yml.

It appears that in your tests the ad hoc command worked using the service module instead of the shell module. Trellis uses the shell module and I was planning to switch it to the service module. It would help us test if you would edit these lines as demonstrated below, then try your deploy again to see if the reload php task succeeds for you.

  - name: Reload php-fpm
-   shell: sudo service php7.0-fpm reload
-   args:
-     chdir: "{{ deploy_helper.new_release_path }}"
+   service:
+     name: php7.0-fpm
+     state: reloaded

edit: just fixed that diff block above

1 Like

Thanks for the help once agin @fullyint.

I have decided to create a quick project with basic settings and use your commands to see if I can get it to work, and if so, then work backwards.

I’ll let you know if I find anything.

Cheers!

No luck as of yet @fullyint.

Still getting the ‘dict object’ issue, however those site urls in the group vars files are all correct.

One thing, is there a way to push my site live without using Trellis for the time being, by copying files over directly to my FTP?

I need my site live by tomorrow as I have an interview and wondered if there is a way around using Trellis for the time being. Just not sure what to do about the WP database, or if anything needs to doing to it at all.

Thanks.

The reload php task is the very last step. If the task hangs/fails, you can do the reload manually, as above. Then you should have your site up for your interview.

However, you’ve since pointed out a couple problems (dict object has no attribute x, invalid repo) that should have caused the playbooks to fail sooner. It leaves me uncertain about how completely your server is provisioned.

You could try to use the server you’ve been working with. You could ssh into your remote, then cd /srv/www/postfiftythree.com/current and work with wp-cli to complete your WordPress setup, if necessary. You may need to rsync/scp/ftp your theme files into place.

Otherwise, if you have your theme files ready but just need a server, you could try the DigitalOcean one-click WordPress install. I’ve never used it. Of course, you could also just use any other host and standard method of installing WordPress and your custom theme.

I’m having this same issue with [deploy : Reload php-fpm] hanging.

I’ve tried changing those three lines but got this error instead:

reload: Rejected send message, 1 matched rules; type="method_call", sender=":1.5050" (uid=1000 pid=32337 comm="reload php7.0-fpm ") interface="com.ubuntu.Upstart0_6.Instance" member="Reload" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init") fatal: [103.16.128.102]: FAILED! => {"changed": false, "failed": true}

If I SSH into the server as web user and try to reload php-fpm it prompts me for a password. (You mentioned this is bad). If I SSH in as root I can reload it.

I tried both those adhoc commands mentioned above and got errors as well.

The ansible-playbook works fine to completion, but I can’t run the deploy. It hangs every time at this same point.

@Simeon I see from other threads that you’ve been working on getting your first successful provision and deploy. It sounds like you have your setup and config all working now but the deploy is just hanging on this final task Reload php-fpm.

If you haven’t tried it already, I’d recommend running server.yml and deploy.yml on a completely fresh VPS/server now that your configs are sorted out. When users have various failed iterations on a given server then encounter an obscure problem (like this thread), the problem is often absent when the users just run their latest setup on a fresh server.

If that doesn’t resolve it, I also noticed this…

Could you tell us whether you have the Reload php-fpm problem on a fresh DO droplet? Could you also tell us if this is Ubuntu 14.04 or something else?

You’re right! I’m learning plenty and trying to get this going…

This is a completely fresh Trellis/Bedrock setup, and I just destroyed and rebuilt my Binary Lane server.

I’ve been able to get Trellis going on DO once before, but it’s imperative I get this working on Binary Lane as DO don’t have an Australian server…

Currently installed: Ubuntu 14.04 LTS (64bit)

More:

ansible "web:&production" -m service -a "name=php7.0-fpm state=reloaded" -u web

Fails

ansible "web:&production" -m service -a "name=php7.0-fpm state=reloaded" -u root

Works