Browse Source

Add admin dashboard option to run health checks (#3606)

There's one for git gc, why not git fsck too?

Also add a couple more trace logs to GitFsck to see progress
tags/v1.5.0-dev
Allen Wild 6 years ago
parent
commit
8606d9f5bc
4 changed files with 12 additions and 0 deletions
  1. 2
    0
      models/repo.go
  2. 2
    0
      options/locale/locale_en-US.ini
  3. 4
    0
      routers/admin/admin.go
  4. 4
    0
      templates/admin/dashboard.tmpl

+ 2
- 0
models/repo.go View File

func(idx int, bean interface{}) error { func(idx int, bean interface{}) error {
repo := bean.(*Repository) repo := bean.(*Repository)
repoPath := repo.RepoPath() 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 { 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) desc := fmt.Sprintf("Failed to health check repository (%s): %v", repoPath, err)
log.Warn(desc) log.Warn(desc)
}); err != nil { }); err != nil {
log.Error(4, "GitFsck: %v", err) log.Error(4, "GitFsck: %v", err)
} }
log.Trace("Finished: GitFsck")
} }


// GitGcRepos calls 'git gc' to remove unnecessary files and optimize the local repository // GitGcRepos calls 'git gc' to remove unnecessary files and optimize the local repository

+ 2
- 0
options/locale/locale_en-US.ini View File

dashboard.reinit_missing_repos_success = All missing Git repositories for which records existed have been reinitialized. 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 = Synchronize external user data
dashboard.sync_external_users_started = External user synchronization started 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.server_uptime = Server Uptime
dashboard.current_goroutine = Current Goroutines dashboard.current_goroutine = Current Goroutines
dashboard.current_memory_usage = Current Memory Usage dashboard.current_memory_usage = Current Memory Usage

+ 4
- 0
routers/admin/admin.go View File

syncRepositoryUpdateHook syncRepositoryUpdateHook
reinitMissingRepository reinitMissingRepository
syncExternalUsers syncExternalUsers
gitFsck
) )


// Dashboard show admin panel dashboard // Dashboard show admin panel dashboard
case syncExternalUsers: case syncExternalUsers:
success = ctx.Tr("admin.dashboard.sync_external_users_started") success = ctx.Tr("admin.dashboard.sync_external_users_started")
go models.SyncExternalUsers() go models.SyncExternalUsers()
case gitFsck:
success = ctx.Tr("admin.dashboard.git_fsck_started")
go models.GitFsck()
} }


if err != nil { if err != nil {

+ 4
- 0
templates/admin/dashboard.tmpl View File

<td>{{.i18n.Tr "admin.dashboard.sync_external_users"}}</td> <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> <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>
<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> </tbody>
</table> </table>
</div> </div>

Loading…
Cancel
Save