• Pierre de La Morinerie's avatar
    Send systemd READY notification (#8296) · b112747d
    Pierre de La Morinerie authored
    Currently, when starting Mattermost programmatically, it's hard to tell
    when the server is actually ready to receive network connections.
    
    This isn't convenient for monitoring (the systemd service status is
    "running" although the server is still booting), nor for programatic use
    (where a script would need to know when the server is ready to perform
    further actions).
    
    To improve this, systemd allow processes to tell when they started
    successfully. The launcher waits for this notification before
    reporting the service as successfully launched.
    
    The way processes notify systemd is by sending a `READY=1` string over
    a standard unix socket, whose path is provided in an environment var.
    
    The systemd service is then told to expect this notification:
    
    ```diff
     [Service]
    -Type=simple
    +Type=notify
     ExecStart=/home/vagrant/go/bin/platform
    ```
    
    Now, when starting the server, systemd will actually wait for the server to
    be ready before returning the control to the shell.
    
    Additionally, during this time, querying the server status with
    `service mattermost status` will report the service as "activating" – before
    transitioning to "running" when the server is ready.
    b112747d
server_test.go 3.71 KB