-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9b945d
commit c598fba
Showing
10 changed files
with
310 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,4 @@ macro_rules! map { | |
//StrMap(map) ; | ||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,12 @@ name = "rg_exts" | |
version = "0.1.0" | ||
authors = ["zuowenjian <[email protected]>"] | ||
|
||
|
||
[dependencies] | ||
log = "0.4.1" | ||
pretty_env_logger = "0.2" | ||
rg_core = { path = "../core", version = "*" } | ||
shells = "0.2" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# from XCodeCraft Template | ||
_env: | ||
- !R.env | ||
_name : "_local_deploy" | ||
_res : | ||
- !R.project | ||
root : "${HOME}/devspace/%{PRJ_NAME}" | ||
name : "%{PRJ_NAME}" | ||
- !R.vars | ||
PHP_ERROR : "E_ALL & ~E_NOTICE" | ||
FPM_USER : "${USER}" | ||
|
||
# 数据库 | ||
# DB_HOST : "127.0.0.1" | ||
# DB_NAME : "db_name" | ||
# DB_USER : "db_user" | ||
# DB_PWD : "" | ||
|
||
- !R.env | ||
_name : "_safe_deploy" | ||
_res : | ||
- !R.project | ||
root : "/data/x/projects/%{PRJ_NAME}" | ||
name : "%{PRJ_NAME}" | ||
- !R.vars | ||
PHP_ERROR : "E_ALL & ~E_NOTICE" | ||
FPM_USER : "%{FPM_USER}" | ||
- !R.env | ||
_name : "_dev" | ||
_res : | ||
- !R.vars | ||
BASE_DOMAIN : "${USER}.%{MAIN_DOMAIN}" | ||
|
||
- !R.env | ||
_name : "_demo" | ||
_res : | ||
- !R.vars | ||
BASE_DOMAIN : "demo.%{MAIN_DOMAIN}" | ||
|
||
- !R.env | ||
_name : "base" | ||
_res : | ||
- !R.vars | ||
PYLON : "/data/x/framework/pylon-ng/" | ||
RIGGER : "/data/x/tools/rigger-ng/" | ||
BASE_INCLUDE : "${PRJ_ROOT}/src/bizlogic:${PRJ_ROOT}/src/foundation" | ||
- !R.path | ||
dst : "${PRJ_ROOT}/conf/used " | ||
|
||
- !R.env | ||
_name : "speed_max" | ||
_res : | ||
- !R.vars | ||
MAX_CHILDREN : "20" | ||
START_SERVERS : "5" | ||
MIN_SPARE_SERVERS : "5" | ||
MAX_SPARE_SERVERS : "10" | ||
- !R.env | ||
_name : "speed_min" | ||
_res : | ||
- !R.vars | ||
MAX_CHILDREN : "5" | ||
START_SERVERS : "2" | ||
MIN_SPARE_SERVERS : "1" | ||
MAX_SPARE_SERVERS : "3" | ||
|
||
- !R.env | ||
_name : "debug" | ||
_res : | ||
- !R.vars | ||
PHP_ERROR : "E_ALL & ~E_NOTICE" | ||
DEBUG : "ON" | ||
LOG_MODE : "DEBUG" | ||
- !R.env | ||
_name : "release" | ||
_res : | ||
- !R.vars | ||
PHP_ERROR : "E_ERROR" | ||
DEBUG : "XOFF" | ||
LOG_MODE : "ONLINE" | ||
|
||
|
||
- !R.env | ||
_name : "dev" | ||
_mix : "_local_deploy,_dev,base,speed_min,debug" | ||
|
||
- !R.env | ||
_name : "demo" | ||
_mix : "_safe_deploy,_demo,base,speed_min,debug" | ||
|
||
- !R.env | ||
_name : "test" | ||
_mix : "_safe_deploy,_test,base,speed_max,release" | ||
|
||
_sys: | ||
- !R.system | ||
_name : "init" | ||
_res : | ||
# - !R.vars | ||
# YOU_X : "x" | ||
# - !R.mysql | ||
# host: "${DB_HOST}" | ||
# name: "${DB_NAME}" | ||
# user: "${DB_USER}" | ||
# password: "${DB_PWD}" | ||
# sql: "${PRJ_ROOT}/src/init/create_db.sql" | ||
- !R.using | ||
path : "${RIGGER}/extends/moduls/pylon.yaml" | ||
modul : "pylon_php" | ||
args : !R.vars | ||
MOD_TAG : "init" | ||
MOD_INCLUDE : "${PRJ_ROOT}/src/init:${BASE_INCLUDE}" | ||
# - !R.php | ||
# ini : "${PRJ_ROOT}/conf/used/init_php.ini" | ||
# script : "${PRJ_ROOT}/src/init/sys_init.php" | ||
|
||
- !R.system | ||
_name : "api" | ||
_res : | ||
- !R.vars | ||
DOMAIN : "api.${BASE_DOMAIN}" | ||
SOCK_FILE : "${RUN_PATH}/api_fpm.sock" | ||
- !R.using | ||
path : "${RIGGER}/extends/moduls/pylon.yaml" | ||
modul : "pylon_web" | ||
args : !R.vars | ||
MOD_TAG : "api" | ||
MOD_ENTRY : "${PRJ_ROOT}/src/sys_${SYS_NAME}" | ||
MOD_INCLUDE : "${PRJ_ROOT}/src/sys_${SYS_NAME}:${BASE_INCLUDE}" | ||
|
||
- !R.system | ||
_name : "test" | ||
_res : | ||
- !R.using | ||
path : "${RIGGER}/extends/moduls/pylon.yaml" | ||
modul : "pylon_php" | ||
args : !R.vars | ||
MOD_TAG : "test" | ||
MOD_INCLUDE : "${PRJ_ROOT}/test:${PRJ_ROOT}/src" | ||
- !R.shell | ||
script : "${PRJ_ROOT}/test/phpunit.sh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
|
||
#[macro_use] extern crate log; | ||
extern crate pretty_env_logger; | ||
#[macro_use] extern crate rg_core ; | ||
#[macro_use] extern crate shells ; | ||
|
||
pub mod unix ; | ||
pub mod service ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
use rg_core::err::* ; | ||
use rg_core::def::* ; | ||
use rg_core::model::* ; | ||
use rg_core::res::* ; | ||
use rg_core::creator::* ; | ||
use std::path::Path ; | ||
|
||
#[derive(Debug)] | ||
pub struct Link | ||
{ | ||
src: String, | ||
dst: String, | ||
|
||
} | ||
impl Loader<Link> for Link | ||
{ | ||
fn load( data : &StrMap) -> Link | ||
{ | ||
let dst = data.must_get(&String::from("dst")).clone() ; | ||
let src = data.must_get(&String::from("src")).clone() ; | ||
Link{ src, dst} | ||
} | ||
fn key() -> String { String::from("Link") } | ||
} | ||
|
||
|
||
|
||
impl InvokeHook for Link{} | ||
impl InvokeStop for Link{ | ||
|
||
} | ||
|
||
|
||
impl ResDesp for Link | ||
{ | ||
fn res_info(&self) -> String { | ||
format!("{:?}",self) | ||
} | ||
fn res_name(&self) -> String { | ||
Link::key() | ||
} | ||
} | ||
|
||
|
||
#[macro_export] | ||
macro_rules! ERR{ | ||
($args:expr) => ({ return Error::Runtime(String::from($args)) }); | ||
($fmt:expr, $($args:tt)*) => ({ | ||
return Err(Error::Runtime(format!($fmt,$($args)*))) | ||
}); | ||
} | ||
|
||
|
||
impl InvokeStart for Link | ||
{ | ||
fn res_conf(&self,_context : &mut Context) ->BoolR | ||
{ | ||
let dst_path = Path::new(self.dst.as_str()) ; | ||
let src_path = Path::new(self.src.as_str()) ; | ||
if dst_path.exists() | ||
{ | ||
if dst_path.read_link().is_ok() | ||
{ | ||
let (code,stdout,stderr )= sh!("unlink {}",self.dst); | ||
if code != 0 { | ||
ERR!("{:?} {:?} ",stdout,stderr); | ||
} | ||
} | ||
else | ||
{ | ||
ERR!("dst exists {:?}",self.dst); | ||
} | ||
} | ||
//TODO: | ||
/* | ||
if src_path.exists() | ||
{ | ||
let parent = dst_path.parent(); | ||
let f_name = dst_path.file_name() ; | ||
if let Some(p) = parent { | ||
if let Some(f) = f_name | ||
{ | ||
let (code,stdout,stderr )= sh!("cd {:?} ; ln -s {} {:?}", p.as_os_str(),self.src, f) ; | ||
if code != 0 { | ||
ERR!("{:?} {:?} ",stdout,stderr); | ||
} | ||
return Ok(()) ; | ||
} | ||
} | ||
} | ||
ERR!("{} not exists",self.src); | ||
*/ | ||
Ok(()) | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
pub fn res_regist(f : &mut ResFatory) | ||
{ | ||
regist_creator::<Link>(f) ; | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests | ||
{ | ||
use super::* ; | ||
//use rg_core::res::* ; | ||
use rg_core::model::* ; | ||
use rg_core::parser::* ; | ||
use rg_core::creator::* ; | ||
use pretty_env_logger ; | ||
#[test] | ||
fn creat_link() | ||
{ | ||
pretty_env_logger::init(); | ||
debug!("hello") ; | ||
let mut god = ResFatory::new() ; | ||
res_regist(&mut god); | ||
let data = map!("dst" =>"${HOME}/devspace/rigger-nx/extends/meterial/run_ngx.yaml","src" => "${HOME}/devspace/rigger-nx/extends/meterial/run_tpl.yaml") ; | ||
let obj = god.create(&Link::key(),&data ).unwrap(); | ||
res_check(&obj); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
pub mod link ; |