I started, but it doesn't start!

Example: Start Apache2

fabric.py


from fabric.api import env, sudo


def servers():
    env.hosts = ["b13t.net"]


def startd():
    sudo("service apache2 start")

Or write, in the shell

$ fab servers startd

If you do

[b13t.net] Executing task 'startd'
[b13t.net] sudo: service apache2 start

[b13t.net] out:  * Starting web server apache2
[b13t.net] out: httpd (pid 20130618) already running
[b13t.net] out:    ...done.
[b13t.net] out: 


Done.
Disconnecting from b13t.net:65537... done.

However, even if you actually enter with ssh and ps ax, apache2 does not exist, and even if you use service apache2 state, it is said that it is Not running and you will experience the despair of this world.

So how do you get rid of despair?

python


def startd():
    sudo("service apache2 start", pty=False)

If you write pty = False, you will be happy without despair. I don't understand because I can't read English, http://stackoverflow.com/questions/6379484/fabric-appears-to-start-apache2-but-doesnt http://docs.fabfile.org/en/1.6/api/core/operations.html#fabric.operations.run If you read here, is the virtual terminal when pty = True leaking some information?

If you specify fabtools with pip install and specify a user who has sufficient authority to env.user in advance, it seems that the following will also start. (Unverified)

python


from fabtools import service
def startd():
    service.start("apache2")

Recommended Posts

I started, but it doesn't start!
I introduced black to vscode, but it doesn't autoformat
When I try to make Apache SSL, it doesn't start.
I started python
I started Docker
[Streamlit] I installed it
I started to analyze
I wondered if Python 3.4 was faster, but it was slower
When I try to push with heroku, it doesn't work
I started PYNQ (2) -Overlay self-made-