Laravel - Artisan Console - Signal Handling
The Symfony Console component, which powers the Artisan console, allows you to indicate which process signals (if any) your command handles. For example, you may indicate that your command handles the SIGINT
and SIGTERM
signals.
To get started, you should implement the Symfony\Component\Console\Command\SignalableCommandInterface
interface on your Artisan command class. This interface requires you to define two methods: getSubscribedSignals
and handleSignal
:
stopServer();
return;
}
}
}
As you might expect, the getSubscribedSignals
method should return an array of the signals that your command can handle, while the handleSignal
method receives the signal and can respond accordingly.