Windows: Cannot launch gitea dump from windows service #4368

Open
opened 2025-11-02 05:48:21 -06:00 by GiteaMirror · 14 comments
Owner

Originally created by @PurdeysBane on GitHub (Nov 21, 2019).

  • Gitea version (or commit ref): 1.9.6
  • Git version: 2.23.0.windows.1
  • Operating system: Windows 10
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

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

Originally created by @PurdeysBane on GitHub (Nov 21, 2019). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.9.6 - Git version: 2.23.0.windows.1 - Operating system: Windows 10 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## 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 <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the issue/confirmed label 2025-11-02 05:48:21 -06:00
Author
Owner

@lunny commented on GitHub (Nov 22, 2019):

Could you specify the config file path.

@lunny commented on GitHub (Nov 22, 2019): Could you specify the config file path.
Author
Owner

@PurdeysBane commented on GitHub (Nov 22, 2019):

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

@PurdeysBane commented on GitHub (Nov 22, 2019): 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
Author
Owner

@guillep2k commented on GitHub (Nov 22, 2019):

@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 on GitHub (Nov 22, 2019): @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`
Author
Owner

@guillep2k commented on GitHub (Nov 22, 2019):

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

@guillep2k commented on GitHub (Nov 22, 2019): Note: you may want to test all this from.... command line first. 😁
Author
Owner

@stale[bot] commented on GitHub (Jan 21, 2020):

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.

@stale[bot] commented on GitHub (Jan 21, 2020): 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.
Author
Owner

@rogeriorc commented on GitHub (Jan 22, 2020):

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.

@rogeriorc commented on GitHub (Jan 22, 2020): Steps to reproduce: Download PsTools (from [SysInternals)](https://docs.microsoft.com/en-us/sysinternals/downloads/psexec) 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.
Author
Owner

@stale[bot] commented on GitHub (Mar 22, 2020):

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.

@stale[bot] commented on GitHub (Mar 22, 2020): 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.
Author
Owner

@rogeriorc commented on GitHub (Mar 22, 2020):

So...?

@rogeriorc commented on GitHub (Mar 22, 2020): So...?
Author
Owner

@lunny commented on GitHub (Mar 24, 2020):

@rogeriorc which version of your gitea instance?

@lunny commented on GitHub (Mar 24, 2020): @rogeriorc which version of your gitea instance?
Author
Owner

@rogeriorc commented on GitHub (Mar 25, 2020):

Hi, @lunny !

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

Thanks!

@rogeriorc commented on GitHub (Mar 25, 2020): Hi, @lunny ! Version 1.11.0 windows amd64 running on a Windows Server 2019 Standard (x64). Thanks!
Author
Owner

@guillep2k commented on GitHub (Mar 26, 2020):

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

@guillep2k commented on GitHub (Mar 26, 2020): @rogeriorc Please notice that you cannot run `dump` while Gitea is running.
Author
Owner

@rogeriorc commented on GitHub (Mar 26, 2020):

@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.

@rogeriorc commented on GitHub (Mar 26, 2020): @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.
Author
Owner

@guillep2k commented on GitHub (Mar 27, 2020):

@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.

@guillep2k commented on GitHub (Mar 27, 2020): @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](https://docs.microsoft.com/en-us/windows/win32/services/localsystem-account). Maybe that's what's causing your inconvenience.
Author
Owner

@inDream commented on GitHub (Apr 9, 2020):

@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

@inDream commented on GitHub (Apr 9, 2020): @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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4368