go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/graceful/start_for_shutdown.go (about)

     1  /*
     2  
     3  Copyright (c) 2024 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package graceful
     9  
    10  import "context"
    11  
    12  // StartForShutdown is a helper that sets up a graceful hosted process
    13  // with default signals. You can pass a context to this function to
    14  // explicitly control shutdown, in addition to setting up notification
    15  // on process signals.
    16  func StartForShutdown(ctx context.Context, hosted ...Service) error {
    17  	return Graceful{
    18  		Hosted:          hosted,
    19  		ShutdownSignals: DefaultShutdownSignals,
    20  		RestartSignals:  DefaultRestartSignals,
    21  	}.StartForShutdown(ctx)
    22  }