Menu
Reference
- Manticore\Ds
- Async
- Classes
- AggregateError
- CancellationToken
- CancelledException
- Channel
- ChannelClosedException
- Context
- DeadlockException
- Mutex
- Once
- Pool
- Received
- SelectCase
- Selected
- Semaphore
- Settled
- Task
- TaskGroup
- TimeoutException
- Functions
- async()
- awaitAll()
- awaitAllSettled()
- awaitAny()
- channel()
- delay()
- dump()
- dumpOn()
- failure()
- group()
- mapConcurrent()
- mapSettled()
- readFile()
- select()
- selectNow()
- selectWithin()
- shield()
- shutdownOn()
- spawn()
- stats()
- timeout()
- watchdog()
- writeFile()
- Http
- Http\WebSocket
- Buffer
- Process
- Io\Poll
- Manticore\Sapi
- Ffi
shutdownOn()
function
function shutdownOn(int ...$signals): void
Graceful shutdown: on any of $signals, cancel the root scope.
Async\async(function () {
Async\shutdownOn(SIGTERM, SIGINT);
serveForever(); // unwinds cleanly on the signal
});This is about scopes, not about signals: everything else follows from cancellation already being structured. The accept loop and every live connection get CancelledException at their next suspend point, each scope joins its children, shield() covers a final flush, and async() returns normally, because a root cancellation is a shutdown, not a failure. The handler is installed with pcntl_signal(); plain pcntl_signal() also works inside async(). Process control (fork, workers, supervision) lives under Process\, not here.
Parameters
...$signalsint- the signal numbers, e.g.
SIGTERM