require 5.004;

###############################################################################
#
# SLURM / Linux
#
#   Adapted from BSC's TSI by Xavier Delaruelle at CEA
#
###############################################################################

# If you are using Perl 5.004 or later, then use the FindBin lines. Otherwise
# you will need to pass the TSI installation directory on the command line
# using "-I" or modify the line below
#use lib "<install directory>";

use FindBin qw($Bin)
  ;    # determines dynamically the directory containing this script
   # and from there the module files (which are installed in the same directory)
use lib $FindBin::Bin;
use strict;

use SharedConfiguration qw(configure_common startup);
$main::tsi_props = shift || "./tsi.properties";
configure_common();

# The TSI code is split into a number of Perl modules to
# allow for easier maintenance. This file contains batch system or
# operating system specific options, while the SharedConfiguration.pm
# the common settings. You should review both files.

# BSS/OS SPECIFIC CONFIGURATION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

# Where to find the SLURM commands used by the TSI
my $slurm_dir = "/usr/bin";

# submit a job to slurm
$main::submit_cmd = "$slurm_dir/sbatch";

# delete a job from slurm, returning stdout/stderr
$main::abort_cmd = "$slurm_dir/scancel";

# delete a job from slurm, deleting stdout/stderr
# WARNING: scancel will not delete stdout and stderr
$main::cancel_cmd = "$slurm_dir/scancel";

# Do we do anything in response to a hold?
$main::site_sez_no_holds = 1;    # 0 => holding allowed

# suspend execution of a batch job
$main::hold_cmd = "$slurm_dir/scontrol suspend";

# suspend, release all resources, execution of a batch job (optional)
# WARNING: no freeze feature in SLURM
#$main::freeze_cmd = "";

# resume execution of a batch job
$main::resume_cmd = "$slurm_dir/scontrol resume";

# show all jobs on SLURM in a format assumed by GetStatusListing
$main::qstat_cmd = "$slurm_dir/squeue -h -o \"%i %T\" ";

# The path from a setuid script is not the correct user path and
# this line should be enabled with a suitable path for user level
# scripts. This line is a minimal set and should be extended with
# any site specific values, particularly those needed for SLURM to
# work correctly (note that "interesting" scripts are run in batch mode
# and so SLURM should ensure that a proper environment is set for these.
# This line just needs to get the scripts into a batch subsystem.)
#
# Disabling this line passes the TSI user's PATH to the user.
$ENV{PATH} = ":/usr/local/bin:/usr/bin:/bin:/usr/lib/java/bin";

$main::my_os = "SLURM";

# END OF CONFIGURATION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

startup();
