init
This commit is contained in:
commit
a117c1fa08
10
boundle.sh
Executable file
10
boundle.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
tag_name=`git status |grep '# On branch '|sed 's/# On branch //g'`
|
||||
dir_name=`basename $PWD`
|
||||
package_name=${dir_name}.tar.gz
|
||||
#echo $tag_name
|
||||
#echo $dir_name
|
||||
#echo $package_name
|
||||
|
||||
tar --exclude=*.git -chzf target/${package_name} webapp config reload.sh restart.sh
|
1
restart.sh
Normal file
1
restart.sh
Normal file
@ -0,0 +1 @@
|
||||
echo 'success'
|
54
webapp/bootstrap/config_loader.php
Normal file
54
webapp/bootstrap/config_loader.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
$g_conf_mysql_cluster = require('../config/game2001api.mysql.cluster.php');
|
||||
$g_conf_redis_cluster = require('../config/game2001api.redis.cluster.php');
|
||||
|
||||
function checkMysqlConfig()
|
||||
{
|
||||
$instance_id = 1;
|
||||
global $g_conf_mysql_cluster;
|
||||
foreach ($g_conf_mysql_cluster as $instance) {
|
||||
if ($instance_id != $instance['instance_id']) {
|
||||
error_log('game2001api.mysql.cluster.php config error');
|
||||
die();
|
||||
}
|
||||
$instance_id++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkRedisConfig()
|
||||
{
|
||||
$instance_id = 1;
|
||||
global $g_conf_redis_cluster;
|
||||
foreach ($g_conf_redis_cluster as $instance) {
|
||||
if ($instance_id != $instance['instance_id']) {
|
||||
error_log('game2001api.redis.cluster.php config error');
|
||||
die();
|
||||
}
|
||||
$instance_id++;
|
||||
}
|
||||
}
|
||||
|
||||
function getMysqlConfig($hash_value)
|
||||
{
|
||||
if ($hash_value < 0) {
|
||||
die('hash_value < 0 ' . $hash_value);
|
||||
}
|
||||
global $g_conf_mysql_cluster;
|
||||
$idx = $hash_value % count($g_conf_mysql_cluster);
|
||||
return $g_conf_mysql_cluster[$idx];
|
||||
}
|
||||
|
||||
function getRedisConfig($hash_value)
|
||||
{
|
||||
if ($hash_value < 0) {
|
||||
die('hash_value < 0 ' . $hash_value);
|
||||
}
|
||||
global $g_conf_redis_cluster;
|
||||
$idx = $hash_value % count($g_conf_redis_cluster);
|
||||
return $g_conf_redis_cluster[$idx];
|
||||
}
|
||||
|
||||
checkMysqlConfig();
|
||||
checkRedisConfig();
|
6
webapp/bootstrap/init.php
Normal file
6
webapp/bootstrap/init.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
require 'phpcommon/common.php';
|
||||
|
||||
require 'config_loader.php';
|
1
webapp/controller/OpsController.class.php
Symbolic link
1
webapp/controller/OpsController.class.php
Symbolic link
@ -0,0 +1 @@
|
||||
../phpcommon/Controller/OpsController.class.php
|
24
webapp/index.php
Normal file
24
webapp/index.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
require 'bootstrap/init.php';
|
||||
|
||||
if (empty($_REQUEST['c']) || empty($_REQUEST['a'])) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
|
||||
function autoload_controller__($classname)
|
||||
{
|
||||
require_once "controller/$classname.class.php";
|
||||
spl_autoload_unregister('autoload_controller__');
|
||||
}
|
||||
spl_autoload_register('autoload_controller__');
|
||||
|
||||
try{
|
||||
$c = $_REQUEST['c'];
|
||||
$a = $_REQUEST['a'];
|
||||
$classname = $c .'Controller';
|
||||
$obj = eval('return (new $classname())->$a();');
|
||||
} catch (Exception $e){
|
||||
echo($e);
|
||||
}
|
1
webapp/phpcommon
Symbolic link
1
webapp/phpcommon
Symbolic link
@ -0,0 +1 @@
|
||||
../third_party/phpcommon
|
Loading…
x
Reference in New Issue
Block a user