Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add admin dashboard option to run health checks #3606

Merged
merged 1 commit into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,7 @@ func GitFsck() {
func(idx int, bean interface{}) error {
repo := bean.(*Repository)
repoPath := repo.RepoPath()
log.Trace(fmt.Sprintf("Running health check for repository %s", repoPath))
if err := git.Fsck(repoPath, setting.Cron.RepoHealthCheck.Timeout, setting.Cron.RepoHealthCheck.Args...); err != nil {
desc := fmt.Sprintf("Failed to health check repository (%s): %v", repoPath, err)
log.Warn(desc)
Expand All @@ -2183,6 +2184,7 @@ func GitFsck() {
}); err != nil {
log.Error(4, "GitFsck: %v", err)
}
log.Trace("Finished: GitFsck")
}

// GitGcRepos calls 'git gc' to remove unnecessary files and optimize the local repository
Expand Down
2 changes: 2 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,8 @@ dashboard.reinit_missing_repos = Reinitialize all missing Git repositories for w
dashboard.reinit_missing_repos_success = All missing Git repositories for which records existed have been reinitialized.
dashboard.sync_external_users = Synchronize external user data
dashboard.sync_external_users_started = External user synchronization started
dashboard.git_fsck = Execute health checks on all repositories
dashboard.git_fsck_started = Repository health checks started
dashboard.server_uptime = Server Uptime
dashboard.current_goroutine = Current Goroutines
dashboard.current_memory_usage = Current Memory Usage
Expand Down
4 changes: 4 additions & 0 deletions routers/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const (
syncRepositoryUpdateHook
reinitMissingRepository
syncExternalUsers
gitFsck
)

// Dashboard show admin panel dashboard
Expand Down Expand Up @@ -161,6 +162,9 @@ func Dashboard(ctx *context.Context) {
case syncExternalUsers:
success = ctx.Tr("admin.dashboard.sync_external_users_started")
go models.SyncExternalUsers()
case gitFsck:
success = ctx.Tr("admin.dashboard.git_fsck_started")
go models.GitFsck()
}

if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions templates/admin/dashboard.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<td>{{.i18n.Tr "admin.dashboard.sync_external_users"}}</td>
<td><i class="fa fa-caret-square-o-right"></i> <a href="{{AppSubUrl}}/admin?op=8">{{.i18n.Tr "admin.dashboard.operation_run"}}</a></td>
</tr>
<tr>
<td>{{.i18n.Tr "admin.dashboard.git_fsck"}}</td>
<td><i class="fa fa-caret-square-o-right"></i> <a href="{{AppSubUrl}}/admin?op=9">{{.i18n.Tr "admin.dashboard.operation_run"}}</a></td>
</tr>
</tbody>
</table>
</div>
Expand Down