Skip to content

Commit

Permalink
1)Adding: add script template for nginx configure to be restored and …
Browse files Browse the repository at this point in the history
…restarted
  • Loading branch information
haveTryTwo committed Apr 20, 2015
1 parent 7af6529 commit 7c72afa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ ENDIF(WIN32)

install(DIRECTORY bin DESTINATION .)
install(DIRECTORY conf DESTINATION .)
install(DIRECTORY script DESTINATION .)
install(DIRECTORY DESTINATION cmd)
install(DIRECTORY DESTINATION dumps)
install(DIRECTORY DESTINATION monitor)
install(DIRECTORY DESTINATION result)
install(DIRECTORY DESTINATION script)
install(DIRECTORY DESTINATION lock)
install(FILES lockfile DESTINATION lock)
install(DIRECTORY DESTINATION doc)
Expand Down
2 changes: 1 addition & 1 deletion agent/qconf_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "qconf_common.h"

// agent version
#define QCONF_AGENT_VERSION "1.0.0"
#define QCONF_AGENT_VERSION "1.0.2"

#define QCONF_AGENT_NAME "qconf_agent"

Expand Down
3 changes: 2 additions & 1 deletion agent/qconf_script.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ int find_script(const string &path, string &script)
return QCONF_ERR_SCRIPT_DIR_NOT_INIT;
}
//find exist script file
string script_path(_qconf_script_dir), tmp_path(path), file_path;
string script_path(_qconf_script_dir), tmp_path, file_path;
tmp_path = (path[0] == '/') ? path.substr(1) : path;
replace(tmp_path.begin(), tmp_path.end(), '/', QCONF_SCRIPT_SEPARATOR);
script_path.append(tmp_path);
size_t index = script_path.size();
Expand Down
23 changes: 23 additions & 0 deletions agent/script/nginx_template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
NODE_ADD=0
NODE_CHANGE=1
NODE_DEL=2

if [ "$qconf_event" != "$NODE_DEL" ]; then
value=`./qconf get_conf $qconf_path`

# TODO: Nginx directory, You may change this to your own directory
nginx=/usr/local/nginx
nginx_conf_path=$nginx/conf/nginx.conf

old_conf_value=`cat $nginx_conf_path`

#if value is modified, then change the file
if [ "$value" != "$old_conf_value" ]; then
cp $nginx_conf_path ${nginx_conf_path}.bak
echo $value > ${nginx_conf_path}.tmp
mv ${nginx_conf_path}.tmp $nginx_conf_path

# TODO: Restart nginx, You may change this to your own command of nginx starting
service nginx restart
fi
fi
2 changes: 1 addition & 1 deletion agent/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
qconf-agent: 1.0.0
qconf-agent: 1.0.2

0 comments on commit 7c72afa

Please sign in to comment.