Aborting and resuming a Symfony Console command

前端 未结 3 1654
無奈伤痛
無奈伤痛 2021-02-02 17:14

I have a Symfony Console command that iterates over a potentially big collection of items and does a task with each of them. Since the collection can be big, the co

3条回答
  •  不要未来只要你来
    2021-02-02 17:29

    You should take a look at RabbitMqBundle's signal handling. Its execute method just links some callbacks via the pcntl_signal() function call. A common case should look pretty much like this:

    writeln('Stopping');
    
            // Do what you need to stop your process
        }
    
        public function restartCommand(OutputInterface $output)
        {
            $output->writeln('Restarting');
    
            // Do what you need to restart your process
        }
    }
    

提交回复
热议问题