fabric appears to start apache2 but doesn't

后端 未结 6 585
不思量自难忘°
不思量自难忘° 2020-12-29 04:27

I\'m using fabric to remotely start a micro aws server, install git and a git repository, adjust apache config and then restart the server.

If at any point, from the

相关标签:
6条回答
  • 2020-12-29 04:57

    Which version of fabric are you running?

    Have you tried to change the pty argument (try to change shell too, but it should not influence things)?

    http://docs.fabfile.org/en/1.0.1/api/core/operations.html#fabric.operations.run

    You can set the pty argument like this:

    sudo('service apache2 restart', pty=False)
    
    0 讨论(0)
  • 2020-12-29 05:02

    using pty=False still didn't solve it for me. The solution that ended up working for me is doing a double-nohup, like so:

    run.sh

    #! /usr/bin/env bash
    nohup java -jar myapp.jar 2>&1 &
    

    fabfile.py

    ...
    sudo("nohup ./run.sh &> nohup.out", user=env.user, warn_only=True)
    ...
    
    0 讨论(0)
  • 2020-12-29 05:06

    When connecting to your remotes on behalf of a user granted enough privileges (such as root), you can manage system services as shown below:

    from fabtools import service
    
    service.restart('apache2')
    

    https://fabtools.readthedocs.org/en/0.13.0/api/service.html

    P.S. Its requires the installation of fabtools

    pip install fabtools

    0 讨论(0)
  • 2020-12-29 05:06

    Couple of more ways to fix the problem.

    • You could run the fab target with --no-pty option

      fab --no-pty <task>
      
    • Inside fabfile, set the global environment variable always_use_pty to False, before your target code executes

      env.always_use_pty = False
      
    0 讨论(0)
  • 2020-12-29 05:07

    Try this:

    sudo('service apache2 restart',pty=False)
    

    This worked for me after running into the same problem. I'm not sure why this happens.

    0 讨论(0)
  • 2020-12-29 05:15

    This is an instance of this issue and there is an entry in the FAQ that has the pty answer. Unfortunately on CentOS 6 doesn't support pty-less sudo commands and I didn't like the nohup solution since it killed output.

    The final entry in the issue mentions using sudo('set -m; service servicename start'). This turns on Job Control and therefore background processes are put in their own process group. As a result they are not terminated when the command ends.

    0 讨论(0)
提交回复
热议问题