go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.45k stars 5.43k forks source link

Windows: Cannot launch gitea dump from windows service #9109

Open PurdeysBane opened 4 years ago

PurdeysBane commented 4 years ago

Description

I am trying to run gitea.exe dump -R from a Windows service. The exe appears to run but immediately returns with exit code 0 without doing anything. It does not create a log file (even if I increase the log level to trace in the app.ini file)

If I run the command line from a command prompt it works as expected. Any idea why gitea is exiting without doing anything?

Screenshots

lunny commented 4 years ago

Could you specify the config file path.

PurdeysBane commented 4 years ago

Thanks but I already tried that and it didn't help.

Further information: It also fails to run from Windows Task scheduler unless running as the current logged in user i.e. it seems that it only works when running from an interactive session

guillep2k commented 4 years ago

@PurdeysBane Try running /path/to/bash with -c "/path/to/gitea --option1 --option2". If command line doesn't work (Windows command prompt parser can be a b*tch), try creating a bash script:

#!/bin/bash

exec /path/to/gitea --option1 --option2 ...

And run it with /path/to/bash /path/to/your/script

guillep2k commented 4 years ago

Note: you may want to test all this from.... command line first. 😁

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

rogeriorc commented 4 years ago

Steps to reproduce:

Download PsTools (from SysInternals)

run:

PsExec.exe -i -s cmd.exe

To open a Command Prompt as Local System Account. Then run a dump command.

gitea.exe dump -V -c "D:\Gitea\custom\conf\app.ini"

Even with the verbose flag, nothing is shown in the command prompt, and no dump file is created.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

rogeriorc commented 4 years ago

So...?

lunny commented 4 years ago

@rogeriorc which version of your gitea instance?

rogeriorc commented 4 years ago

Hi, @lunny !

Version 1.11.0 windows amd64 running on a Windows Server 2019 Standard (x64).

Thanks!

guillep2k commented 4 years ago

@rogeriorc Please notice that you cannot run dump while Gitea is running.

rogeriorc commented 4 years ago

@guillep2k the docs say:

Backup Command (dump) Switch to the user running Gitea: su git. Run ./gitea dump -c /path/to/app.ini in the Gitea installation directory. There should be some output similar to the following:

It works when I'm use a user account, even the administrator account.

guillep2k commented 4 years ago

@rogeriorc That's right, however the dump command doesn't produce consistent results if the instance is running, because it's just a succession of SELECT ... FROM ... statements.

Anyway, be aware that we strongly discourage running Gitea as System (or root in *nix systems) for security reasons.

Back to your problem, the Local System account has the peculiarity of not having a proper user profile. Maybe that's what's causing your inconvenience.

inDream commented 4 years ago

@guillep2k @rogeriorc I think this is related to logger cannot get default file name. It fixed after changed value for [log.file] FILE_NAME = gitea.log