Skip to content

Commit 76494d0

Browse files
committed
system init write install.log file
1 parent 3cd5ee9 commit 76494d0

File tree

4 files changed

+34
-121
lines changed

4 files changed

+34
-121
lines changed

bootstrap/bootstrap_install.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
use Symfony\Component\HttpFoundation\ParameterBag;
44
use Topxia\Service\Common\ServiceKernel;
55

6-
require __DIR__ . '/../vendor/autoload.php';
6+
require_once __DIR__ . '/../vendor/autoload.php';
77

88
define("INSTALL_URI", "\/install\/start-install.php");
9+
define("ROOT_DIR", realpath(__DIR__ . '/../app'));
910

1011
$serviceKernel = ServiceKernel::create('prod', true);
1112
$serviceKernel->setParameterBag(new ParameterBag(array(
12-
'kernel.root_dir' => realpath(__DIR__ . '/../app')
13+
'kernel.root_dir' => ROOT_DIR
1314
)));
1415

1516

@@ -28,11 +29,11 @@
2829
'driver' => $parameters['database_driver'],
2930
'charset' => 'UTF8'
3031
),
31-
'cache_directory' => "%kernel.root_dir%/../var/cache",
32-
'tmp_directory' => "%kernel.root_dir%/../var/tmp",
33-
'log_directory' => "%kernel.root_dir%/../var/logs",
34-
'plugin.directory' => "%kernel.root_dir%/../plugins",
35-
'plugin.config_file' => "%kernel.root_dir%/config/plugin_installed.php"
32+
'cache_directory' => ROOT_DIR . '/cache',
33+
'tmp_directory' => ROOT_DIR . '/tmp',
34+
'log_directory' => ROOT_DIR . '/logs',
35+
'plugin.directory' => ROOT_DIR . '/../plugins',
36+
'plugin.config_file' => ROOT_DIR . '/config/plugin_installed.php'
3637
));
3738

3839
$biz['migration.directories'][] = dirname(__DIR__) . '/migrations';

src/Topxia/Common/SystemInitializer.php

+12-107
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
1010
use Symfony\Component\Console\Input\InputDefinition;
1111
use Symfony\Component\Console\Input\InputInterface;
12+
use Symfony\Component\Console\Output\NullOutput;
1213
use Symfony\Component\Console\Output\OutputInterface;
14+
use Symfony\Component\Console\Output\StreamOutput;
1315
use Symfony\Component\Filesystem\Filesystem;
1416
use Topxia\Service\Common\ServiceKernel;
1517
use Topxia\Service\Content\BlockService;
@@ -26,19 +28,23 @@
2628

2729
class SystemInitializer
2830
{
29-
protected $input;
3031
protected $output;
3132

32-
public function __construct(InputInterface $input=null, OutputInterface $output=null)
33+
public function __destruct()
3334
{
34-
if($input === null){
35-
$input = new EmptyInput();
35+
if(isset($this->outputFd) && is_resource($this->outputFd)){
36+
@fclose($this->outputFd);
3637
}
38+
}
3739

40+
public function __construct(OutputInterface $output=null)
41+
{
3842
if($output === null){
39-
$output = new EmptyOutput();
43+
global $biz;
44+
$this->outputFd = @fopen($biz['log_directory'] . '/install.log', 'w');
45+
$output = new StreamOutput($this->outputFd);
4046
}
41-
$this->input = $input;
47+
4248
$this->output = $output;
4349
}
4450

@@ -780,105 +786,4 @@ protected function getDictionaryService()
780786
{
781787
return ServiceKernel::instance()->createService('Dictionary.DictionaryService');
782788
}
783-
}
784-
785-
786-
787-
788-
class EmptyInput implements InputInterface
789-
{
790-
public function getFirstArgument()
791-
{
792-
}
793-
794-
public function hasParameterOption($values)
795-
{
796-
}
797-
798-
public function getParameterOption($values, $default = false)
799-
{
800-
}
801-
802-
public function bind(InputDefinition $definition)
803-
{
804-
}
805-
806-
public function validate()
807-
{
808-
}
809-
810-
public function getArguments()
811-
{
812-
}
813-
814-
public function getArgument($name)
815-
{
816-
}
817-
818-
public function setArgument($name, $value)
819-
{
820-
}
821-
822-
public function hasArgument($name)
823-
{
824-
}
825-
826-
public function getOptions()
827-
{
828-
}
829-
830-
public function getOption($name)
831-
{
832-
}
833-
834-
public function setOption($name, $value)
835-
{
836-
}
837-
838-
public function hasOption($name)
839-
{
840-
}
841-
842-
public function isInteractive()
843-
{
844-
}
845-
846-
public function setInteractive($interactive)
847-
{
848-
}
849-
}
850-
851-
class EmptyOutput implements OutputInterface
852-
{
853-
public function write($messages, $newline = false, $options = 0)
854-
{
855-
}
856-
857-
public function writeln($messages, $options = 0)
858-
{
859-
}
860-
861-
public function setVerbosity($level)
862-
{
863-
}
864-
865-
public function getVerbosity()
866-
{
867-
}
868-
869-
public function setDecorated($decorated)
870-
{
871-
}
872-
873-
public function isDecorated()
874-
{
875-
}
876-
877-
public function setFormatter(OutputFormatterInterface $formatter)
878-
{
879-
}
880-
881-
public function getFormatter()
882-
{
883-
}
884789
}

src/Topxia/WebBundle/Command/BuildCommand.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Topxia\WebBundle\Command;
33

44
use Symfony\Component\Console\Input\ArrayInput;
5+
use Symfony\Component\Console\Input\InputArgument;
56
use Symfony\Component\Console\Input\InputInterface;
67
use Symfony\Component\Console\Output\NullOutput;
78
use Symfony\Component\Console\Output\OutputInterface;
@@ -35,7 +36,13 @@ class BuildCommand extends BaseCommand
3536

3637
protected function configure()
3738
{
38-
$this->setName('topxia:build');
39+
$this->setName('build:install-package')
40+
->setDescription('自动编制安装包(含演示数据)')
41+
->addArgument('domain', InputArgument::REQUIRED, '演示站点域名')
42+
->addArgument('user', InputArgument::REQUIRED, '演示站点数据库用户')
43+
->addArgument('password', InputArgument::REQUIRED, '数据库密码')
44+
->addArgument('database', InputArgument::REQUIRED, '演示站数据库')
45+
;
3946
}
4047

4148
protected function execute(InputInterface $input, OutputInterface $output)
@@ -105,10 +112,10 @@ private function buildDatabase()
105112

106113
$input = new ArrayInput(array(
107114
'command' => 'topxia:dump-init-data',
108-
'domain' => 'exam.edusoho.cn',
109-
'user' => 'exam.edusoho.cn',
110-
'password'=> 'edusoho',
111-
'database'=> 'exam.edusoho.cn'
115+
'domain' => $this->input->getArgument('domain'),
116+
'user' => $this->input->getArgument('user'),
117+
'password'=> $this->input->getArgument('password'),
118+
'database'=> $this->input->getArgument('database')
112119
));
113120

114121
$returnCode = $dumpCommand->run($input, $this->output);
@@ -125,7 +132,7 @@ private function buildDatabase()
125132

126133
$helper = $this->getHelper('question');
127134
$question = new ConfirmationQuestion(
128-
'请确认已经将演示数据sql中的cloud_access_key和cloud_secret_key修改为12345(值前面表示字符串长度的数字s:5也要改)/ Y:N',
135+
'请确认已经将演示数据sql中的cloud_access_key和cloud_secret_key修改为12345(值前面表示字符串长度的数字s:5也要改) Y/N:',
129136
false
130137
);
131138

src/Topxia/WebBundle/Command/InitCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
2121

2222
$this->installAssets($output);
2323
$this->initServiceKernel();
24-
$initializer = new SystemInitializer($input, $output);
24+
$initializer = new SystemInitializer($output);
2525
$fields = array(
2626
'email' => '[email protected]',
2727
'nickname' => '测试管理员',

0 commit comments

Comments
 (0)