cancel
Showing results for 
Search instead for 
Did you mean: 

Can you change an environment variable at runtime?

JustinPiche
Level 2
I have a large batch process that interacts in a page hosted by a cloud service. The process is ran by 3 resources, 1 master and 2 slaves--they work out of the same queue of up to 1000 records at a time. I've noticed that over the course of a couple hours, as the process runs, the browser will occasionally stop responding which doesn't come as a surprise since it's working in a browser for hours at a time. I created a re-spawn routine for the slave resources which closes the browser, initiates the process again and the slaves continue working out of the same queue. The master bot however is programmed to truncate the queue at the beginning of processing under the assumption that it's initiating a new batch UNLESS a rerun environment variable is flagged to true, in which case the Master will behave as a slave and just continue processing out of the existing queue. My question is, is it possible to change environment variables at runtime? My thought is, for the master bot, if it's determined it needs to re-spawn, the rerun environment variable can be switched to true in order to preserve the existing queue and then it can continue to process records until it completes at which point the environment variable can be switched back to false for the subsequent job, the following day.  Thought? Suggestions? Thanks JP    
5 REPLIES 5

John__Carter
Staff
Staff
Hi JP - you could re-purpose a work queue item, credential or env lock status to exchange a value between sessions. The command line and HTTP APIs provide mechanisms for changing an env var or session var, but implementing these would be more fairly complicated.

RobertoCarbonet
Level 3
Hi JP - some other possibilities are the use of the Environment Lock or more easy could be also to write a file (into a shared directory or Web service exposed) with the run time needed value.  

John__Carter
Staff
Staff
JP  - I just remembered that even if you did modify an env var, an already running process will not pick up the new value because it holds on to the original value it loaded up at the start.

SandeepAlluri
Level 5
Hi JP, Have you tried using Session variable instead of Environment Variable?

Anonymous
Not applicable
Even if you change enviroment variable at run time the value will chnage but that change value will not be picked.