Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def create_package(target)
sh "cp packaging/wrapper.sh #{package_dir}/#{PROFILE[:package_name]}"
sh "cp packaging/keepalive #{package_dir}/keepalive"
sh "cp packaging/reset-key.sh #{package_dir}/reset-key"
sh "cp packaging/cagent_updater.sh #{package_dir}/cagent_updater"
sh "chmod +x #{package_dir}/#{PROFILE[:package_name]}"
sh "cp -pR packaging/vendor #{package_dir}/lib/"
sh "cp Gemfile Gemfile.lock #{package_dir}/lib/vendor/"
Expand Down
12 changes: 9 additions & 3 deletions init.d/cloudstats-agent
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ progpath='/home/cloudstats_agent/cloudstats-agent'

# binary name
prog=cloudstats-agent
update_script=cagent_updater
keepalive_prog="$homepath/keepalive"

# pid file
pidfile="/var/run/${prog}.pid"

update_pidfile="/var/run/cagent_updater.pid"
# check the binary if not there exit
! [ -x $progpath ] && echo "$progpath: Agent not found" && exit 1

Expand Down Expand Up @@ -56,21 +57,26 @@ start() {
local pid=$!
echo $pid > $pidfile

$homepath/$update_script > /dev/null 2>&1 &
local update_pid=$1
echo $update_pid > $update_pidfile

# check again if it's running
ps -p $pid >/dev/null 2>&1
eval_cmd $?
}

stop() {
# check if it's running
local pids="$(pidof -cx $keepalive_prog) $(pidof -c $prog)"
local pids="$(pidof -cx $keepalive_prog) $(pidof -c $prog) $(pidof -cx $update_script)"

if [ ${#pids} -lt 2 ]; then
if [ ${#pids} -lt 3 ]; then
echo "$prog not running"
return 0
fi
printf "%-50s%s" "Stopping $prog: " ''
rm -f $pidfile
rm -f $update_pidfile
kill -9 $pids
eval_cmd $?
}
Expand Down
12 changes: 6 additions & 6 deletions lib/cloudstats/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def schedule
publisher.publish
end

$logger.info "Scheduling updates every #{update_rate}"
scheduler.every update_rate do
$logger.catch_and_log_socket_error(Updater.STORAGE_SERVICE) do
Updater.new.update
end
end
# $logger.info "Scheduling updates every #{update_rate}"
# scheduler.every update_rate do
# $logger.catch_and_log_socket_error(Updater.STORAGE_SERVICE) do
# Updater.new.update
# end
# end

$logger.info "Scheduling backups"
scheduler.cron '0 0 * * *' do
Expand Down
9 changes: 9 additions & 0 deletions packaging/cagent_updater.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

export INSTALL_PATH="/home/cloudstats_agent"

while :
do
/home/cloudstats_agent/cloudstats-agent --update
sleep 5m
done