Also use alarm to clean up hung pred processes
rodzic
bd2bf925b7
commit
e689ab9096
|
@ -16,6 +16,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "ini/iniparser.h"
|
#include "ini/iniparser.h"
|
||||||
#include "util/gopt.h"
|
#include "util/gopt.h"
|
||||||
|
@ -39,6 +40,7 @@ int main(int argc, const char *argv[]) {
|
||||||
float burst_alt, ascent_rate, drag_coeff, rmswinderror;
|
float burst_alt, ascent_rate, drag_coeff, rmswinderror;
|
||||||
int descent_mode;
|
int descent_mode;
|
||||||
int scenario_idx, n_scenarios;
|
int scenario_idx, n_scenarios;
|
||||||
|
int alarm_time;
|
||||||
char* endptr; // used to check for errors on strtod calls
|
char* endptr; // used to check for errors on strtod calls
|
||||||
|
|
||||||
wind_file_cache_t* file_cache;
|
wind_file_cache_t* file_cache;
|
||||||
|
@ -54,7 +56,8 @@ int main(int argc, const char *argv[]) {
|
||||||
gopt_option('t', GOPT_ARG, gopt_shorts('t'), gopt_longs("start_time")),
|
gopt_option('t', GOPT_ARG, gopt_shorts('t'), gopt_longs("start_time")),
|
||||||
gopt_option('i', GOPT_ARG, gopt_shorts('i'), gopt_longs("data_dir")),
|
gopt_option('i', GOPT_ARG, gopt_shorts('i'), gopt_longs("data_dir")),
|
||||||
gopt_option('d', 0, gopt_shorts('d'), gopt_longs("descending")),
|
gopt_option('d', 0, gopt_shorts('d'), gopt_longs("descending")),
|
||||||
gopt_option('e', GOPT_ARG, gopt_shorts('e'), gopt_longs("wind_error"))
|
gopt_option('e', GOPT_ARG, gopt_shorts('e'), gopt_longs("wind_error")),
|
||||||
|
gopt_option('a', GOPT_ARG, gopt_shorts('a'), gopt_longs("alarm"))
|
||||||
));
|
));
|
||||||
|
|
||||||
if (gopt(options, 'h')) {
|
if (gopt(options, 'h')) {
|
||||||
|
@ -74,6 +77,7 @@ int main(int argc, const char *argv[]) {
|
||||||
printf(" burst or cutdown. burst_alt and ascent_rate ignored.\n");
|
printf(" burst or cutdown. burst_alt and ascent_rate ignored.\n");
|
||||||
printf(" -i --data_dir <dir> Input directory for wind data, defaults to current dir.\n\n");
|
printf(" -i --data_dir <dir> Input directory for wind data, defaults to current dir.\n\n");
|
||||||
printf(" -e --wind_error <err> RMS windspeed error (m/s).\n");
|
printf(" -e --wind_error <err> RMS windspeed error (m/s).\n");
|
||||||
|
printf(" -a --alarm <seconds> Use alarm() to kill pred incase it hangs.\n");
|
||||||
printf("The scenario file is an INI-like file giving the launch scenario. If it is\n");
|
printf("The scenario file is an INI-like file giving the launch scenario. If it is\n");
|
||||||
printf("omitted, the scenario is read from standard input.\n");
|
printf("omitted, the scenario is read from standard input.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -85,6 +89,15 @@ int main(int argc, const char *argv[]) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gopt_arg(options, 'a', &argument) && strcmp(argument, "-")) {
|
||||||
|
alarm_time = strtol(argument, &endptr, 0);
|
||||||
|
if (endptr == argument) {
|
||||||
|
fprintf(stderr, "ERROR: %s: invalid alarm length\n", argument);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
alarm(alarm_time);
|
||||||
|
}
|
||||||
|
|
||||||
verbosity = gopt(options, 'v');
|
verbosity = gopt(options, 'v');
|
||||||
|
|
||||||
if (gopt(options, 'd'))
|
if (gopt(options, 'd'))
|
||||||
|
|
|
@ -249,7 +249,12 @@ def main():
|
||||||
|
|
||||||
update_progress(gfs_percent=100, gfs_timeremaining='Done', gfs_complete=True, pred_running=True)
|
update_progress(gfs_percent=100, gfs_timeremaining='Done', gfs_complete=True, pred_running=True)
|
||||||
|
|
||||||
subprocess.call([pred_binary, '-i/var/www/hab/predict/gfs/', '-v', '-o'+uuid_path+'flight_path.csv', uuid_path+'scenario.ini'])
|
if options.alarm:
|
||||||
|
alarm_flags = ["-a120"]
|
||||||
|
else:
|
||||||
|
alarm_flags = []
|
||||||
|
|
||||||
|
subprocess.call([pred_binary, '-i/var/www/hab/predict/gfs/', '-v', '-o'+uuid_path+'flight_path.csv', uuid_path+'scenario.ini'] + alarm_flags)
|
||||||
|
|
||||||
update_progress(pred_running=False, pred_complete=True)
|
update_progress(pred_running=False, pred_complete=True)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue