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 "Required-Start: $network" to the sysv init script #1246

Closed
Mosney opened this issue Dec 9, 2019 · 20 comments
Closed

Add "Required-Start: $network" to the sysv init script #1246

Mosney opened this issue Dec 9, 2019 · 20 comments

Comments

@Mosney
Copy link

Mosney commented Dec 9, 2019

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • [Y] I am running the latest version
  • [Y] I checked the documentation and found no answer
  • [Y] I checked to make sure that this issue has not already been filed

Problem Description

I install ADG at my OpenWrt router which use a USB drive, and I set work dir in /var which is tmpfs to avoid too much writing. like #876
I found ADG did not function when I restart my router, I check log and found the reason. ADG start before network ready, ADG only try once at the beginning and do nothing when network not ready, so it will run without any rule until next update interval.

Proposed Solution

Add retry time or interval when cannot download rule file correctly.

Additional Information

Log Screenshot:

image

@ameshkov
Copy link
Member

ameshkov commented Dec 9, 2019

Hm, AdGuard service should not start until the network is ready.

@szolin have we made this change in v0.100 or v0.99?

@szolin
Copy link
Contributor

szolin commented Dec 9, 2019

in v0.99
But we only made it for systemd service. OpenWrt may use another service mechanism.

@Mosney
Copy link
Author

Mosney commented Dec 9, 2019

in v0.99
But we only made it for systemd service. OpenWrt may use another service mechanism.

Yep, OpenWrt use /etc/init.d

@Mosney
Copy link
Author

Mosney commented Dec 9, 2019

ref #1201 ,
I also open an issue in luci-app-adguardhome, and dev talk to me it is limited can luci do, but he will try add some delay before run.
In addition, ADG as a DNS resolver in OpenWrt listen port 53, run without rule not a big problem, totally not run may not good thing. So, I think ADG add some retry mechanism better than delay run.

@ameshkov
Copy link
Member

ameshkov commented Dec 9, 2019

I wonder is that possible with simply changing the service configuration?

@rufengsuixing
Copy link

ifup don`t means network is ready ,maybe need to run pppoe.So i will add a ping test on boot start

@Mosney
Copy link
Author

Mosney commented Dec 9, 2019

I wonder is that possible with simply changing the service configuration?

Maybe can add some conditional delay. But I still think retry after failure is essential for a program.

@ameshkov ameshkov added this to the v0.101 milestone Dec 9, 2019
@ameshkov ameshkov changed the title [Feature request]Add retry interval when download rule files face network issue Add "Required-Start: $network" to the sysv init script Dec 9, 2019
@ameshkov
Copy link
Member

ameshkov commented Dec 9, 2019

I really don't think this is a good solution.

We should instead add Required-Start: $network to the sysv script.

@szolin check the kardianos/service code, it allows redefining the sysv script.

There's no Required-Start specified in the default version of the script:

### BEGIN INIT INFO
# Provides:          {{.Path}}
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: {{.DisplayName}}
# Description:       {{.Description}}
### END INIT INFO

@Mosney
Copy link
Author

Mosney commented Dec 10, 2019

About service, I had tried ./AdGuardHome -s install in OpenWrt before I use luci-app-adguardhome. And it is not compatible with OpenWrt's init.d(ref:https://openwrt.org/docs/techref/initscripts). But it is not a problem until ADG supports OpenWrt officially.

@rufengsuixing
Copy link

if support init.d,there must be a lot of args to fill,a luci is needed.Maybe ADG supports OpenWrt officially can do better than me.

@ameshkov
Copy link
Member

@rufengsuixing does OpenWrt support Required-Start: directive? If so, it makes sense to add Required-Start: $network there as well

@rufengsuixing
Copy link

rufengsuixing commented Dec 10, 2019

@rufengsuixing does OpenWrt support Required-Start: directive? If so, it makes sense to add Required-Start: $network there as well

IMG_20191210_164732
you can see from here, k means kill ,s means start.
adH is the s95 after the s20 network ,but still ,because network is ok not means the network can be access to the internet,may need to have pppoe dial or something else,such as Internet authentication need usr to enter the username and password

@rufengsuixing
Copy link

i can make Adg restart every ifup,but there will be a lot of meanless restart

@ameshkov
Copy link
Member

ameshkov commented Dec 10, 2019

I've just realized that the original issue is not about network - it is about tmpfs access at the moment when AGH starts.

Can't it be handled by modifying the AGH init script -- adding tmpfs initialization there?

@rufengsuixing
Copy link

rufengsuixing commented Dec 10, 2019

it is about download rules failed retry interval.
tmpfs always can be access,initialize at very beginning

@Mosney
Copy link
Author

Mosney commented Dec 11, 2019

@ameshkov tmpfs always can be accessed, but no rule files after reboot, so the original issue is

ADG start before network ready, ADG only try once at the beginning and do nothing when network not ready, so it will run without any rule until next update interval.

@ameshkov
Copy link
Member

Quick question: can you backup the rules from tmpfs to normal FS and restore it on device startup?

@rufengsuixing
Copy link

i can and in my luci project i had added it

@szolin
Copy link
Contributor

szolin commented Jan 14, 2020

We can't be sure the network is available when AGH is starting, that's why we just need to fix the filters downloading mechanism. I think we can use a smaller time interval (starting at 5 sec and growing up to an hour which is by default now).

@Mosney
Copy link
Author

Mosney commented Jan 15, 2020

We can't be sure the network is available when AGH is starting, that's why we just need to fix the filters downloading mechanism. I think we can use a smaller time interval (starting at 5 sec and growing up to an hour which is by default now).

Looks good, just what I said at first,

Add retry time or interval when cannot download rule file correctly.

It's a similar solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants