SonarQube: is it possible to change the time zone in the JVM parameters? - sonarqube

I have a machine that runs several different servers and it's in a specific time zone in Central Europe.
I need to run SonarQube (4.5.7) in UTC time.
I uncommented the following line in web/WEB-INF/config/environment.rb and restarted SonarQube but the server still shows the original time zone on the System Info page.
config.time_zone = 'UTC'
Should that be enough to change the time zone in SonarQube? Because that didn't really work.
Is there a way I can pass the user.timezone property to the JVM by editing the wrapper.conf file? Looks like it could work but it doesn't look like I'm supposed to touch that file.
Thanks.

Internal files, including web/**/*, must not be touched.
To change JVM timezone, you should edit conf/sonar.properties and add the value -Duser.timezone=Europe/Sofia to properties sonar.web.javaAdditionalOpts, sonar.ce.javaAdditionalOpts and sonar.search.javaAdditionalOpts.

Related

How to apply timezone to Log4j2 RollingFile?

There seems to be a bug in the past, hasn't it been fixed yet?
Even if a separate timezone is applied to my console log and file name, the actual rollover time is always the server time.
Is there any way to make this rollover time follow my timezone?

Detect if ZONEINFO fails in Go

In Go, you can specify a specific zoneinfo.zip file to be used by adding a ZONEINFO environment variable that points to the specific file you'd like to use for time zone information. This is great as it allows me to ensure that the versions of the IANA time zone database that I'm using on my front-end and my back-end are the same.
However, there does not appear to be any way to detect if use of the specified zone info file has failed. Looking at the source code (https://golang.org/src/time/zoneinfo.go), it looks like any errors using the specified file will fail quietly and then go will proceed to check for default OS locations or the default $GOROOT location to pull time zone information from there. This is not the behavior that I would prefer as I would like to know with certainty that I am using my specified version of zone info.
I've thought of the following in terms of solutions, but I'm not happy with any of them.
I can check that the environment variable is set myself, but this is at best a partial solution as it doesn't tell me if the file is actually usable by LoadLocation.
I can ensure none of the backup locations for zone info exist. This seems a bit extreme and means that I have to be extremely careful about the environment that the code is running in in both dev and production settings.
Does anyone know of a more elegant way to ensure that I am using the zoneinfo.zip file specified by my ZONEINFO environment variable?
Update: To address this problem I too inspiration from #chuckx's answer below and put together a Go package that takes the guess work out of which time zone database is being used. Included in the readme are instructions on how to get the correct version of the time zone database using a Go installation.
Maybe consider not relying on the environment variable?
If you're not averse to distributing the unzipped fileset, you can easily use LoadLocationFromTZData(name string, data []byte). The second argument is the contents of an individual timezone file.
For reference, the functionality for processing a zip file is found in the unexported function loadTzinfoFromZip().
Step-by-step approach extracted from #Slotherooo's comment:
Make a local version of time.loadTzinfoFromZip(zipfile, name string) ([]byte, error)
Use that method to extract the []byte for the desired location from a timeinfo.zip file
Use time.LoadLocationFromTZData() exclusively instead of time.LoadLocation

What timezone is Heroku server using?

What timezone does Heroku's servers use? I'm trying to use node-cron and have the timezones line up, but I can't understand what timezone Heroku is using. Here's an example.
2015-11-30T09:16:45.874086+00:00
By default Heroku will return calls for current time in UTC.
You can manually set your app's time zone by adding a TZ environment variable via the config command. Keep in mind that you must use the tz database time zone format. For example, if you wanted to set your default time zone to US Central time you would use the following command (I'm assuming you have/use heroku toolbelt) :
heroku config:add TZ="America/Chicago"
EDIT: As treecoder points out in the comment below; the TZ ENV variable can be added via the Heroku dashboard if you prefer. Open your app's dashboard and navigate to the 'settings' tab, then under 'config variables' click the 'reveal config vars' button. You will then be able to add TZ = America/Chicago (or whatever timezone you need).
NOTE: The TZ environment variable does not affect logs. See the second note here.
Heroku is UTC by default. Open your app in heroku and go to app setting and click on Reveal Config Vars as in image
and you have to add var as in image
TZ=Asia/kolkata
Then it will work fine for INDIA time zone. you can choose your time zone from time-zone-list.
Heroku is UTC by default. You can change it by setting an env var to TZ=America/New_York or whatever, but I highly recommend you don't.
It's really good practice to keep all your server stuff (Heroku, CMS, etc.) in sync at UTC, and to only change this when displaying times clientside with something like Luxon.
Keeping this stuff in sync will save you a lot of headaches.
According to this, Heroku Help Log, you can change it with TZ variable. However, this never changes your log times, as they are always UTC.

Can I change time zone of ArangoDB's logs?

I live in Japan, so wanna change time zone of ArangoDB's logs from default to UTC+9:00.
Maybe I have to change somewhere of config files but I couldn't make sense.
The time zone is always GMT. You could open a feature request on github https://github.com/triAGENS/ArangoDB/issues maybe a config option can be added. But this needs to be checked.

How can you set time zone setting per user?

Is there a way to set the time zone information to be unique for each Windows user? Like, a registry setting specific to that user.
For example, I want John to be CST and Mary to be PST. If John opens a program it says 5pm. If Mary opens a program it says 6pm.
Additional information: These users don't need to actually log in. I want to create two users, one for CST and one for PST, and use their credentials to run a program. The program will inherit their time zone settings and display the correct time.
More info: I plan on using these users in IIS for app pools so that different applications in the website can be run in different time zones and locales.
Thanks.
The only way Windows supports this is through Terminal Services, which won't help you. The time-zone settings are kept in the HKLM hive, and Terminal Services has a special setting that allows the Terminal Server to take a time-zone supplied by the incoming client-session and display that instead.
A better plan would be to use the timezone offsets in your code. StackOverflow is a better place to ask about that.
I haven't tried, but perhaps via cygwin you can use the TZ Environmental variable like under Unix/Linux. Env variables can be set on the command line by placing them before the command called - eg TZ=UTC xxxx.

Resources