Skip to content

Commit

Permalink
Merge branch 'AdguardTeam:master' into feature/filters-list-per-client
Browse files Browse the repository at this point in the history
  • Loading branch information
hoang-rio authored Jun 18, 2024
2 parents 2dbb4e4 + 66877c9 commit 783a2b7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,34 @@ NOTE: Add new changes BELOW THIS COMMENT.
### Changed

- Frontend rewritten in TypeScript.
- The `systemd`-based service now uses `journal` for logging by default. It
also doesn't create the `/var/log/` directory anymore ([#7053]).

**NOTE:** With an installed service for changes to take effect, you need to
reinstall the service using `-r` flag of the [install script][install-script]
or via the CLI (with root privileges):

```sh
./AdGuardHome -s uninstall
./AdGuardHome -s install
```

Don't forget to backup your configuration file and other important data before
reinstalling the service.

### Deprecated

- Node 18 support, Node 20 will be required in future releases.

### Fixed

- Tracking `/etc/hosts` file changes causing panics within particular
filesystems on start ([#7076]).

[#7053]: https://github.com/AdguardTeam/AdGuardHome/issues/7053

[install-script]: https://github.com/AdguardTeam/AdGuardHome/?tab=readme-ov-file#automated-install-linux-and-mac

<!--
NOTE: Add new changes ABOVE THIS COMMENT.
-->
Expand Down
3 changes: 2 additions & 1 deletion internal/aghnet/hostscontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func (hc *HostsContainer) handleEvents() {

defer close(hc.updates)

ok, eventsCh := true, hc.watcher.Events()
eventsCh := hc.watcher.Events()
ok := eventsCh != nil
for ok {
select {
case _, ok = <-eventsCh:
Expand Down
31 changes: 31 additions & 0 deletions internal/aghos/fswatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,34 @@ func (w *osWatcher) handleErrors() {
log.Error("%s: %s", osWatcherPref, err)
}
}

// EmptyFSWatcher is a no-op implementation of the [FSWatcher] interface. It
// may be used on systems not supporting filesystem events.
type EmptyFSWatcher struct{}

// type check
var _ FSWatcher = EmptyFSWatcher{}

// Start implements the [FSWatcher] interface for EmptyFSWatcher. It always
// returns nil error.
func (EmptyFSWatcher) Start() (err error) {
return nil
}

// Close implements the [FSWatcher] interface for EmptyFSWatcher. It always
// returns nil error.
func (EmptyFSWatcher) Close() (err error) {
return nil
}

// Events implements the [FSWatcher] interface for EmptyFSWatcher. It always
// returns nil channel.
func (EmptyFSWatcher) Events() (e <-chan event) {
return nil
}

// Add implements the [FSWatcher] interface for EmptyFSWatcher. It always
// returns nil error.
func (EmptyFSWatcher) Add(_ string) (err error) {
return nil
}
4 changes: 3 additions & 1 deletion internal/home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ func configureOS(conf *configuration) (err error) {
func setupHostsContainer() (err error) {
hostsWatcher, err := aghos.NewOSWritesWatcher()
if err != nil {
return fmt.Errorf("initing hosts watcher: %w", err)
log.Info("WARNING: initializing filesystem watcher: %s; not watching for changes", err)

hostsWatcher = aghos.EmptyFSWatcher{}
}

paths, err := hostsfile.DefaultHostsPaths()
Expand Down
10 changes: 5 additions & 5 deletions internal/home/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,9 @@ var launchdConfig = `<?xml version='1.0' encoding='UTF-8'?>
// 1. The RestartSec setting is set to a lower value of 10 to make sure we
// always restart quickly.
//
// 2. The ExecStartPre setting is added to make sure that the log directory is
// always created to prevent the 209/STDOUT errors.
// 2. The StandardOutput and StandardError settings are set to redirect the
// output to the systemd journal, see
// https://man7.org/linux/man-pages/man5/systemd.exec.5.html#LOGGING_AND_STANDARD_INPUT/OUTPUT.
const systemdScript = `[Unit]
Description={{.Description}}
ConditionFileIsExecutable={{.Path|cmdEscape}}
Expand All @@ -471,16 +472,15 @@ ConditionFileIsExecutable={{.Path|cmdEscape}}
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStartPre=/bin/mkdir -p /var/log/
ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}}
{{if .UserName}}User={{.UserName}}{{end}}
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
{{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}}
{{if and .LogOutput .HasOutputFileSupport -}}
StandardOutput=file:/var/log/{{.Name}}.out
StandardError=file:/var/log/{{.Name}}.err
StandardOutput=journal
StandardError=journal
{{- end}}
{{if gt .LimitNOFILE -1 }}LimitNOFILE={{.LimitNOFILE}}{{end}}
{{if .Restart}}Restart={{.Restart}}{{end}}
Expand Down

0 comments on commit 783a2b7

Please sign in to comment.