user_settings.py 8.89 KB
Newer Older
jtchilders's avatar
jtchilders committed
1
2
3
4
5
6
7
8
import os,sys,logging
logger = logging.getLogger(__name__)
import socket

logger.info('loading settings')

try:
   INSTALL_PATH                        = os.environ['ARGOBALSAM_INSTALL_PATH']
9
10
   DATA_PATH                           = os.path.join(INSTALL_PATH,'data')
   ALLOWED_EXE_PATH                    = os.path.join(INSTALL_PATH,'exe')
Thomas Uram's avatar
Thomas Uram committed
11
except KeyError as e:
jtchilders's avatar
jtchilders committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
   logger.error('Environment not setup: ' + str(e))
   raise

#------------------------------
# DATABASE CONFIG INFO
#------------------------------
USING_DB_LOGIN                      = False
DBUSER                              = ''
DBPASS                              = ''
if USING_DB_LOGIN:
   DBUSER                           = os.environ['ARGOBALSAM_DBUSER']
   DBPASS                           = os.environ['ARGOBALSAM_DBPASS']

# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
default_db = {}
default_db['ENGINE'] = 'django.db.backends.sqlite3'
default_db['NAME'] = os.path.join(INSTALL_PATH,'db.sqlite3')
if USING_DB_LOGIN:
   default_db['USER'] = DBUSER
   default_db['PASSWORD'] = DBPASS

DATABASES = {
    'default': default_db
}

#------------------------------
# BALSAM CONFIG INFO
#------------------------------
BALSAM_LOGGING_DIRECTORY            = os.path.join(INSTALL_PATH, 'log') # where to store log files
BALSAM_WORK_DIRECTORY               = os.path.join(DATA_PATH,'balsamjobs') # where to store local job data used for submission
BALSAM_DELETE_OLD_WORK              = True # enable deletion of old folders in BALSAM_WORK_DIRECTORY at a period of BALSAM_DELETE_OLD_WORK_PERIOD
BALSAM_DELETE_OLD_WORK_PERIOD       = 86400 # once a day check for old work folders older than the BALSAM_DELETE_OLD_WORK_AGE
BALSAM_DELETE_OLD_WORK_AGE          = 86400 * 31 # delete work folders that are older than 31 days
BALSAM_SERVICE_LOG_FILENAME         = os.path.join(BALSAM_LOGGING_DIRECTORY, 'balsam_service.log')
47
48
49
BALSAM_SCHEDULER_SUBMIT_EXE         = '/usr/bin/qsub'
BALSAM_SCHEDULER_STATUS_EXE         = '/usr/bin/qstat'
BALSAM_SCHEDULER_HISTORY_EXE        = '/usr/bin/'
jtchilders's avatar
jtchilders committed
50
51
52
BALSAM_SERVICE_PERIOD               = 10 # seconds between service loop execution
BALSAM_MAX_QUEUED                   = 20 # the maximum number of jobs allowed on the local queue
BALSAM_SUBMIT_JOBS                  = True # submit jobs to queue, turn off when testing
53
54
BALSAM_DEFAULT_QUEUE                = 'debug-cache-quad' # default local queue name
BALSAM_DEFAULT_PROJECT              = 'datascience' # default local project name
jtchilders's avatar
jtchilders committed
55
BALSAM_ALLOWED_EXECUTABLE_DIRECTORY = ALLOWED_EXE_PATH # path to allowed executables
56
BALSAM_SITE                         = 'theta' # local balsam site name
57
BALSAM_SCHEDULER_CLASS              = 'CobaltScheduler' # local scheduler in use
jtchilders's avatar
jtchilders committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
BALSAM_SCHEDULER_SUBMIT_SCRIPT      = os.path.join(BALSAM_ALLOWED_EXECUTABLE_DIRECTORY,'submit.sh')
BALSAM_SCHEDULER_USE_SUBMIT_SCRIPT  = True
BALSAM_MAX_CONCURRENT_TRANSITIONS   = 5 # maximum number of sub threads spawned by Balsam

#------------------------------
# ARGO CONFIG INFO
#------------------------------
ARGO_LOGGING_DIRECTORY              = BALSAM_LOGGING_DIRECTORY
ARGO_SERVICE_LOG_FILENAME           = os.path.join(ARGO_LOGGING_DIRECTORY,'argo_service.log')
ARGO_SERVICE_PERIOD                 = 10 # seconds between service loop execution
ARGO_WORK_DIRECTORY                 = os.path.join(DATA_PATH,'argojobs')
ARGO_DELETE_OLD_WORK                = True # enable deletion of old folders in BALSAM_WORK_DIRECTORY at a period of ARGO_DELETE_OLD_WORK_PERIOD
ARGO_DELETE_OLD_WORK_PERIOD         = 86400 # in seconds,  once a day check for old work folders older than
ARGO_DELETE_OLD_WORK_AGE            = 86400 * 31 # in seconds,  delete work folders that are older than 31 days
ARGO_MAX_CONCURRENT_TRANSITIONS     = 5 # maximum number of sub threads spawned by ARGO


#------------------------------
# GRID FTP SERVER INFO
#------------------------------

79
GRIDFTP_BIN                         = '/soft/data-transfer/globus/bin'
jtchilders's avatar
jtchilders committed
80
81
82
83
GRIDFTP_GLOBUS_URL_COPY             = os.path.join(GRIDFTP_BIN,'globus-url-copy')
GRIDFTP_PROXY_INFO                  = os.path.join(GRIDFTP_BIN,'grid-proxy-info')
GRIDFTP_PROXY_INIT                  = os.path.join(GRIDFTP_BIN,'grid-proxy-init')
GRIDFTP_PROTOCOL                    = 'gsiftp://'
84
GRIDFTP_SERVER                      = ''
jtchilders's avatar
jtchilders committed
85
86

#------------------------------
87
88
89
# MESSAGING CONFIG
# Specify everything in a SENDER_CONFIG for BalsamStatusSender
# And in RECEIVER_CONFIG for BalsamJobReceiver
jtchilders's avatar
jtchilders committed
90
#------------------------------
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#SENDER_CONFIG = {
#    "mode"                          : "pika",
#    "username"                      : '',
#    "password"                      : '',
#    "host"                          : '',
#    "port"                          : '',
#    "virtual_host"                  : '',
#    "socket_timeout"                : '',
#    "exchange_name"                 : '',
#    "exchange_type"                 : '',
#    "exchange_durable"              : '',
#     "exchange_auto_delete"         : '',
#    "queue_name"                    : '',
#    "queue_is_durable"              : '',
#    "queue_is_exclusive"            : '',
#    "queue_is_auto_delete"          : '',
#    "default_routing_key"           : '',
#     "ssl_cert"                     : '',
#    "ssl_key"                       : '',
#     "ssl_ca_cer"                   : ''
#}
#RECEIVER_CONFIG = {
#    "mode"                          : "pika",
#    "username"                      : '',
#    "password"                      : '',
#    "host"                          : '',
#    "port"                          : '',
#    "virtual_host"                  : '',
#    "socket_timeout"                : '',
#    "exchange_name"                 : '',
#    "exchange_type"                 : '',
#    "exchange_durable"              : '',
#     "exchange_auto_delete"         : '',
#    "queue_name"                    : '',
#    "queue_is_durable"              : '',
#    "queue_is_exclusive"            : '',
#    "queue_is_auto_delete"          : '',
#    "default_routing_key"           : '',
#     "ssl_cert"                     : '',
#    "ssl_key"                       : '',
#     "ssl_ca_cer"                   : ''
#}

RECEIVER_CONFIG = {
    "mode" : "no_message"
}
jtchilders's avatar
jtchilders committed
137

138
139
140
SENDER_CONFIG = {
    "mode" : "no_message"
}
jtchilders's avatar
jtchilders committed
141
142
143
144
145
146
147
148
149
150
151
152
153


#------------------------------
# logging settings
#------------------------------
LOG_HANDLER_LEVEL = 'DEBUG'
LOG_BACKUP_COUNT = 5 # number of files worth of history
LOG_FILE_SIZE_LIMIT = 100 * 1024 * 1024 # file size at which to move to a new log file
LOG_HANDLER_FILENAME = os.path.join(ARGO_LOGGING_DIRECTORY,'argo_balsam.' + str(os.getpid()) + '.log')
if 'argo_service' in sys.argv:
   LOG_HANDLER_FILENAME = ARGO_SERVICE_LOG_FILENAME
elif 'balsam_service' in sys.argv:
   LOG_HANDLER_FILENAME = BALSAM_SERVICE_LOG_FILENAME
Thomas Uram's avatar
Thomas Uram committed
154
print('logging to ' + str(LOG_HANDLER_FILENAME))
jtchilders's avatar
jtchilders committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234

LOGGING = {
   'version': 1,
   'disable_existing_loggers': False,
   'formatters': {
      'standard': {
      'format' : '%(asctime)s|%(process)d|%(levelname)8s|%(name)s:%(lineno)s] %(message)s',
      'datefmt' : "%d-%b-%Y %H:%M:%S"
      },
   },
   'handlers': {
      'time_rotating': {
         'level':LOG_HANDLER_LEVEL,
         'class':'logging.handlers.TimedRotatingFileHandler',
         'filename': LOG_HANDLER_FILENAME,
         'when' : 'W0',
         'interval' : 0,
         'formatter': 'standard',
         'backupCount': '2',
      },
      'console': {
         'class':'logging.StreamHandler',
         'formatter': 'standard',
      },
      'default': {
         'level':LOG_HANDLER_LEVEL,
         'class':'logging.handlers.RotatingFileHandler',
         'filename': LOG_HANDLER_FILENAME,
         'maxBytes': LOG_FILE_SIZE_LIMIT,
         'backupCount': LOG_BACKUP_COUNT,
         'formatter': 'standard',
      }
   },
   'loggers': {
      'django':{
         'handlers': ['default'],
         'level': 'DEBUG',
         'propagate': True,
      },
      'argo': {
         'handlers': ['default'],
         'level': 'DEBUG',
      },
      'common': {
         'handlers': ['default'],
         'level': 'DEBUG',
      },
      'console': {
         'handlers': ['console'],
         'level': 'INFO',
      },
      'balsam': {
         'handlers': ['default'],
         'level': 'DEBUG',
      },
      'django.db.backends': {
         'handlers':['default'],
         'level': 'WARNING',
      },
      'pika.adapters.base_connection': {
         'handlers':['default'],
         'level':'WARNING',
      },
   }
}

#------------------------------
# Sanity Checks
#------------------------------

# ensure that requisite paths exist
for d in [
      INSTALL_PATH,
      DATA_PATH,
      ALLOWED_EXE_PATH,
      BALSAM_LOGGING_DIRECTORY,
      BALSAM_WORK_DIRECTORY,
      BALSAM_ALLOWED_EXECUTABLE_DIRECTORY,
      ARGO_LOGGING_DIRECTORY,
      ARGO_WORK_DIRECTORY,
235
236
237
238
239
240
      #GRIDFTP_GLOBUS_URL_COPY,
      #GRIDFTP_PROXY_INFO,
      #GRIDFTP_PROXY_INIT,
      #RABBITMQ_SSL_CERT,
      #RABBITMQ_SSL_KEY,
      #RABBITMQ_SSL_CA_CERTS,
jtchilders's avatar
jtchilders committed
241
242
   ]:
   if not os.path.exists(d):
243
      os.makedirs(d)
jtchilders's avatar
jtchilders committed
244
245
246
247