mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-12 03:05:34 +08:00
add cs fixer and PHPStan and activate it (build 436)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ZM\Command\Generate;
|
||||
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -15,28 +15,31 @@ class SystemdGenerateCommand extends Command
|
||||
// the name of the command (the part after "bin/console")
|
||||
protected static $defaultName = 'generate:systemd';
|
||||
|
||||
protected function configure() {
|
||||
$this->setDescription("生成框架的 systemd 配置文件");
|
||||
protected function configure()
|
||||
{
|
||||
$this->setDescription('生成框架的 systemd 配置文件');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config');
|
||||
$path = $this->generate();
|
||||
$output->writeln("<info>成功生成 systemd 文件,位置:" . $path . "</info>");
|
||||
$output->writeln("<info>有关如何使用 systemd 配置文件,请访问 `https://github.com/zhamao-robot/zhamao-framework/issues/36`</info>");
|
||||
$output->writeln('<info>成功生成 systemd 文件,位置:' . $path . '</info>');
|
||||
$output->writeln('<info>有关如何使用 systemd 配置文件,请访问 `https://github.com/zhamao-robot/zhamao-framework/issues/36`</info>');
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function generate() {
|
||||
private function generate()
|
||||
{
|
||||
$s = "[Unit]\nDescription=zhamao-framework Daemon\nAfter=rc-local.service\n\n[Service]\nType=simple";
|
||||
$s .= "\nUser=" . exec("whoami");
|
||||
$s .= "\nUser=" . exec('whoami');
|
||||
$s .= "\nGroup=" . exec("groups | awk '{print $1}'");
|
||||
$s .= "\nWorkingDirectory=" . getcwd();
|
||||
global $argv;
|
||||
$s .= "\nExecStart=" . PHP_BINARY . " {$argv[0]} server";
|
||||
$s .= "\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\n";
|
||||
@mkdir(getcwd() . "/resources/");
|
||||
file_put_contents(ZMConfig::get("global", "zm_data") . "zhamao.service", $s);
|
||||
return ZMConfig::get("global", "zm_data") . "zhamao.service";
|
||||
@mkdir(getcwd() . '/resources/');
|
||||
file_put_contents(ZMConfig::get('global', 'zm_data') . 'zhamao.service', $s);
|
||||
return ZMConfig::get('global', 'zm_data') . 'zhamao.service';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user