Best practice - determining what region you are on
Hello all,
I have a question about what you think the best practice is to determine what region you are running on when you have a system setup with a DEV/TEST, QA, and PROD regions running the same scripts in all.
So, when you run in DEV, you have a different directory structure, and you don't want to email the entire group when you are testing something and you abend.
We use the hostname to determine what box we are running on, then a case statement that has the box names hardcoded.
Right there is the problem. Our hardware group just moved us from one box to another, and even though they kept the old DNS available and pointing to the new box, the hostname found the new box name - and nothing worked.
Yes, we missed the fact that the hostname was hardcoded in the common environment script, but this is where my question comes in.
What do you do to prevent having to make ANY changes to your scripts when the hostname changes due to a box move, but you can still tell you are running in DEV or QA or PROD?
The only thing that comes immediately to mind is a file located on each box, uniquely named for that box - something as simple as prod.dat, qa.dat, dev.dat. If one of those files exist, a case tells you what region you are in. However - that also has risk. Some newbie deletes it. If it's hidden - what if the SA doesn't copy it to the new box?
Another approach... Move all the 'environmental' depend dependencies from being 'hard-wired' in the script itself into a separate configuration script which gets "sources" by the 'main' script.
One of the settings in the config file could be:
You could reference the var ENVIRON in your main script and make needed choices without changing the script itself.
just my $.02
A script shouldn't know need to know or care whether it's in dev or production; never hardcode anything.
Directory paths: if [ "$HOSTNAME" = "DEV" ] is a bad idea. Do something like . /etc/myservice.conf. Then do sanity checks on every path to make sure they're valid and have sufficient access permissions, etc, etc, etc. If they're not, clearly log which one has failed and why before exiting safely. Use one myservice.conf in development, ship another to install it somewhere else.
Email: Depends on how your script handles that. It may be possible to leave it up to the server where email goes.
For that matter: Why are the settings so different in your development server than your deployment ones?
Another approach... Move all the 'environmental' depend dependencies from being 'hard-wired' in the script itself into a separate configuration script which gets "sources" by the 'main' script.
One of the settings in the config file could be:
You could reference the var ENVIRON in your main script and make needed choices without changing the script itself.
just my $.02
We have a configuration script - and we have used the type of approach you are talking about. However, that means that the environmental scripts are not IDENTICAL between the regions, which is something you want to prevent things being added and removed are done for each region. We also use PVCS for promoting, and each script should work as is, untouched, in each region.
Quote:
Originally Posted by Corona688
A script shouldn't know need to know or care whether it's in dev or production; never hardcode anything.
I agree! However, we have not found a good alternative to this one.
Quote:
Originally Posted by Corona688
Directory paths: if [ "$HOSTNAME" = "DEV" ] is a bad idea. Do something like . /etc/myservice.conf. Then do sanity checks on every path to make sure they're valid and have sufficient access permissions, etc, etc, etc. If they're not, clearly log which one has failed and why before exiting safely. Use one myservice.conf in development, ship another to install it somewhere else.
Email: Depends on how your script handles that. It may be possible to leave it up to the server where email goes.
For that matter: Why are the settings so different in your development server than your deployment ones?
To answer your last question first - at one time we had our DEV and QA regions on the same box. Therefore we could not have (ex) /app/scripts represent our scripts directory for both DEV and QA. So, we came up with /app/test/scripts for dev, and /app/prod/scripts for BOTH QA and Production. The theory is that QA should look exactly as production does, hence the same directory names.
Other things also create a need to handling things differently between regions, such as dealing with different DSNs on the MVS we have to communicate and send files to. Their dev region names are TEST.D, QA is TEST.X, prod is PCS.P. Our environmental script that determines what region we are running in, sets variables to build the correct DSN on the MVS, which may be participating in the test. The email thing - that's a safety feature. If a developer (and that's who we are - developers trying to figure this best practice) is working on a project, pressed for time, and everyone's hollering about getting the test emails, he can tell the script that when in DEV, send them to his email. Then if he forgets to change that back to the group email - the script handles it by saying "When I'm running in prod, send the email to the group".
Your first suggestion - sanity checks on directory names. If the directories are identical between QA and PROD, then directory checks to determine differences in the regions would not be able to tell the difference.
If you're not willing to use config files, you should enforce the same configuration on all three servers so your scripts don't have to change. Install symlinks if necessary.
Until you do, something, somewhere, will always have to know all the per-server settings for each server.
Quote:
The email thing - that's a safety feature.
But why's it handled in your script and not on the server? Have the default sendmail address or somesuch end up in a mailing list on your dev server, or the other proper destination in production, instead of hardcoding different behavior in your script.
Quote:
Your first suggestion - sanity checks on directory names. If the directories are identical between QA and PROD, then directory checks to determine differences in the regions would not be able to tell the difference.
That's not what they're for, and checking like you suggest isn't something your script ought to be doing.
Either use config files, or enforce the same configuration everywhere, don't build an unmaintainable rube-goldberg machine.
Hi,
I would like to know how can I get a mean score value by ID over a defined genomic region. Here it is an example:
file1
12 100 103 id1
12 110 112 id1
12 200 203 id2
file2
12 100 101 1
12 101 102 0.8
12 102 103 0.7
12 110 111 2.5
12 111 112 2.8
12 200 201 10.1
12 201 202... (7 Replies)
Hello, I am trying to concatenate two strings by merging the overlapped region. E.g.
Seq1=ACGTGCCC
Seq2=CCCCCGTGTGTGT
Seq_merged=ACGTGCCCCCGTGTGTGTFunction strcat(char *dest, char *src) appends the src string to the dest string, ignoring the overlapped parts (prefix of src and suffix of dest).... (30 Replies)
Input file
2 5 ASFGEWTEWRQWEQ
10 20 QEWIORUEIOUEWORUQWEQWRQRQWGQWGFQ
1 6 WRQTQWTQTQWTQT
Desired output file
2 5 ASFGEWTEWRQWEQ
10 20 QEWIORUEIOUEWORUQWEQWRQRQWGQWGFQ
1 6 WRQTQWTQTQWTQT
Column 1 is the start region of underline the text in column 3;
Column 2 is the end region of... (13 Replies)
Dears my rootvg is missed up i can not extend the /opt
as soon as i try to extend the Filesystem its give me that there is not enough space .
as there any way to change the REGION of the LVs in HDISK1 ?
lspv -p hdisk0
hdisk0:
PP RANGE STATE REGION LV NAME TYPE ... (8 Replies)
How can I find the regions between specific lines?
I have a file which contains lines like this:
chr1 0 17388 0
chr1 17388 17444 1
chr1 17444 17599 2
chr1 17599 17601 1
chr1 17601 569791 0
chr1 569791 569795 1
chr1 569795 569808 2
chr1 569808 569890 3
chr1 569890 570047 4 ... (9 Replies)
Hi guys,
I hope everybody is doing fine. I have written this small program which solves the critical region problem. Only on of the two threads can make changes to a common variable called counter. I am using two semaphores, is it possible to write the same program using only one semaphore? Here... (0 Replies)
Hi:
Let's suppose I want to replace all the | by > ONLY when | is between . Usually (and it works) I would do something like
sed -e 's/\(\*\)|\(*\]\)/\1>\2/g'
where I have to "save" some portions of the matched region and use them with the \n metacharacter. I was wondering if I could... (2 Replies)