胡斌

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
cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE}
server: _prepare_dir
@echo "build the srs(simple rtmp server) over st(state-threads)"
./scripts/version.sh
\$(MAKE) -f ${SRS_OBJS_DIR}/${SRS_MAKEFILE} srs
srs_ingest_hls: _prepare_dir
@echo "build the srs_ingest_hls for srs"
... ...
#ifndef VERSION_H
#define VERSION_H
#define VERSION_STRING $FULL_VERSION
#endif
... ...
#!/bin/bash
rm -f src/version.h
git rev-list HEAD | sort > git_rev_list
LOCALVER=`wc -l git_rev_list | awk '{print $1}'`
BRANCH=$(git branch | grep "\*" | awk '{print $2}')
echo branch:$BRANCH
if [ $LOCALVER -ge 1 ] ; then
VER=${LOCALVER}
if git status | grep -q "modified:" ; then
VER="${VER}M"
fi
GIT_VERSION="$BRANCH r$VER $(git rev-list HEAD -n 1 | cut -c 1-8)"
else
GIT_VERSION="$BRANCH none"
fi
rm -f git_rev_list
GIT_VERSION="${GIT_VERSION} $(date "+%Y-%m-%d %H:%M:%S")"
cat scripts/version.h.tmpl | sed "s/\$FULL_VERSION/\"$GIT_VERSION\"/g" > objs/version.h
echo "save to version.h:$GIT_VERSION"
... ...
... ... @@ -46,11 +46,12 @@ using namespace std;
#include <srs_kernel_file.hpp>
#include <srs_app_utility.hpp>
#include <srs_core_performance.hpp>
#include "../../objs/version.h"
using namespace _srs_internal;
// the version to identify the core.
const char* _srs_version = "XCORE-"RTMP_SIG_SRS_SERVER;
const char* _srs_version = "XCORE-"RTMP_SIG_SRS_SERVER": "VERSION_STRING;
#define SRS_WIKI_URL_LOG "https://github.com/ossrs/srs/wiki/v1_CN_SrsLog"
... ... @@ -1552,6 +1553,9 @@ int SrsConfig::check_config()
{
int ret = ERROR_SUCCESS;
//output _srs_version to log
srs_trace(_srs_version);
srs_trace("srs checking config...");
////////////////////////////////////////////////////////////////////////
... ...