#!/usr/bin/tclsh cd [file dirname [info script]] # Copy the files from the source directory to the production directory. # Keep one old version in the production directory, too. Then restart the # appropriate processes # Note: It's common for more than one project to live on the same machine. # What if you want to upgrade all of the new alert and top list servers? If # you tried to run the upgrade scripts for the alerts and the top list # separately, you'd have a problem. On any machine running both servers, you'd # overwrite the old version with the newest version. I.e. fast_alert_search # and fast_alert_search.1 would be identical. # This script allows you to upgrade multiple projects at once. We only do the # copying once for each machine, even if that machine has multiple projects # running on it. This means that fast_alert_search.1 will be correct. set servers { alert_ms { dir ../alert_ms/hosts process fast_alert_search_alert_ms description {modern alerts} } tl_ms { dir ../toplist_ms/hosts process fast_alert_search_tl_ms description {modern top lists} } top_list { dir ../toplist_old/hosts process fast_alert_search_top_listXXXXX description {top lists for older clients} } } # TODO # # If you try to upgrade the old top lists, this script will fail with an error # message. # # Currently the run_top_list script only runs the program once. All of the # newer scripts rerun the program in a loop. That means we can restart a # program by killing it. That also means if the program dies for some other # reason it will automatically restart, which is a very good thing. # # When I wrote this script I thought that all of the programs ran in a loop. # I could change this script so it calls run_top_list instead of killall for # the old top lists. But it seems better to fix the run_top_list script to # work like the others. # # As a temporary measure I renamed the top list process to something that # doesn't exist. So if you try to upgrade the old top list, you'll get an # error message immediately. if {[llength $argv] == 0} { set message {Please list one or more servers on the command line} dict for {name info} $servers { append message \n $name " " ( [dict get $info description] ) } puts stderr $message exit 1 } foreach server $argv { set info [dict get $servers $server] set dir [dict get $info dir] set hosts [glob -tails -directory $dir *] lappend to_upgrade {*}$hosts set to_restart([dict get $info process]) $hosts } set to_upgrade [lsort -unique $to_upgrade] foreach host $to_upgrade { puts "ssh $host cpp_alert_server/live_server/fast_alert_search/upgrade" exec >@ stdout 2>@ stderr ssh $host cpp_alert_server/live_server/fast_alert_search/upgrade } set first 1 foreach process [array names to_restart] { foreach host $to_restart($process) { if {$first} { set $first 0 } else { after 15000 } puts "ssh $host killall $process" exec >@ stdout 2>@ stderr ssh $host killall $process } }