胡斌

print git version string to console and logfile when server start up.

git version string example:2.0+ r3504M 6bf24238 2017-02-28 19:10:44
which means: branch , revison index, commit hash, date time
@@ -348,6 +348,7 @@ else @@ -348,6 +348,7 @@ else
348 cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE} 348 cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
349 server: _prepare_dir 349 server: _prepare_dir
350 @echo "build the srs(simple rtmp server) over st(state-threads)" 350 @echo "build the srs(simple rtmp server) over st(state-threads)"
  351 + ./scripts/version.sh
351 \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} srs 352 \$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} srs
352 srs_ingest_hls: _prepare_dir 353 srs_ingest_hls: _prepare_dir
353 @echo "build the srs_ingest_hls for srs" 354 @echo "build the srs_ingest_hls for srs"
  1 +#ifndef VERSION_H
  2 +#define VERSION_H
  3 +
  4 +#define VERSION_STRING $FULL_VERSION
  5 +
  6 +#endif
  1 +#!/bin/bash
  2 +rm -f src/version.h
  3 +git rev-list HEAD | sort > git_rev_list
  4 +LOCALVER=`wc -l git_rev_list | awk '{print $1}'`
  5 +BRANCH=$(git branch | grep "\*" | awk '{print $2}')
  6 +echo branch:$BRANCH
  7 +if [ $LOCALVER -ge 1 ] ; then
  8 + VER=${LOCALVER}
  9 + if git status | grep -q "modified:" ; then
  10 + VER="${VER}M"
  11 + fi
  12 + GIT_VERSION="$BRANCH r$VER $(git rev-list HEAD -n 1 | cut -c 1-8)"
  13 +else
  14 + GIT_VERSION="$BRANCH none"
  15 +fi
  16 +rm -f git_rev_list
  17 +
  18 +GIT_VERSION="${GIT_VERSION} $(date "+%Y-%m-%d %H:%M:%S")"
  19 +
  20 +cat scripts/version.h.tmpl | sed "s/\$FULL_VERSION/\"$GIT_VERSION\"/g" > objs/version.h
  21 +
  22 +echo "save to version.h:$GIT_VERSION"
@@ -46,11 +46,12 @@ using namespace std; @@ -46,11 +46,12 @@ using namespace std;
46 #include <srs_kernel_file.hpp> 46 #include <srs_kernel_file.hpp>
47 #include <srs_app_utility.hpp> 47 #include <srs_app_utility.hpp>
48 #include <srs_core_performance.hpp> 48 #include <srs_core_performance.hpp>
  49 +#include "../../objs/version.h"
49 50
50 using namespace _srs_internal; 51 using namespace _srs_internal;
51 52
52 // the version to identify the core. 53 // the version to identify the core.
53 -const char* _srs_version = "XCORE-"RTMP_SIG_SRS_SERVER; 54 +const char* _srs_version = "XCORE-"RTMP_SIG_SRS_SERVER": "VERSION_STRING;
54 55
55 #define SRS_WIKI_URL_LOG "https://github.com/ossrs/srs/wiki/v1_CN_SrsLog" 56 #define SRS_WIKI_URL_LOG "https://github.com/ossrs/srs/wiki/v1_CN_SrsLog"
56 57
@@ -1552,6 +1553,9 @@ int SrsConfig::check_config() @@ -1552,6 +1553,9 @@ int SrsConfig::check_config()
1552 { 1553 {
1553 int ret = ERROR_SUCCESS; 1554 int ret = ERROR_SUCCESS;
1554 1555
  1556 + //output _srs_version to log
  1557 + srs_trace(_srs_version);
  1558 +
1555 srs_trace("srs checking config..."); 1559 srs_trace("srs checking config...");
1556 1560
1557 //////////////////////////////////////////////////////////////////////// 1561 ////////////////////////////////////////////////////////////////////////