I was working on a python script that uses subprocess to run the
gogs backup command to take a backup, then upload the newly minted archive to S3. Naturally, I would schedule this as a cron job, but when I looked at the output I found the following error:
2017/12/18 13:00:02 [FATAL] [...g/setting/setting.go:571 NewContext()] Expect user 'gogs' but current user is:
INSTALL_LOCK is set in the app.ini I was encountering an issue where the current user was not the
RUN_USER. In this case the fatal error is reporting that the current user is an empty string. Digging into https://github.com/gogits/gogs/blob/master/pkg/user/user.go it appears that this user check is looking at the environment variable USER which must not be set either when running this in cron or when using subprocess in script.
The solution was to simply add
os.environ['USER'] = 'gogs' to my python script. Hope this saves you all some grief if you try the same thing.