-
Notifications
You must be signed in to change notification settings - Fork 324
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 watchdog script written in Lua to the gluon-mesh-vpn-tunneldigger #1735
Conversation
package. The logic is based on the former watchdog written in (B)ash. The code was written bei Robin Weiligmann <admin@robwei.me> and me.
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
Please use tabs for indentation everywhere. |
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
…esh-vpn connectivity. Minor refractoring.
Thanks for your feedback, @mweinelt. The latest commit does the requested changes. |
Done in last commit. Had overseen it before. |
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
The Gluon codebase uses lowercase function names with underlines separating words, not camel casing as you do.
|
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
…espect of coding convetions. Changed logic in read_pid_file for readability.
✓ |
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
…ith respect to coding convetions.
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mixed single and double quotes a lot in your file. This is very inconsistent in the rest of Gluon. However, while you are at it, you might want to bring a bit of consistency in your own file.
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
- Fix quotation style - refractoring / code optimization
Thanks for your feedback, @blocktrron. I tried to address all points in the last commit. |
package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog
Outdated
Show resolved
Hide resolved
Great progress, please test the latest version and report back. |
I just tested it in x86-64. Works :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but since I cannot test this myself, will someone with a tunneldigger setup give this a testdrive and make sure this works as intended?
I already tested it...works. Do you want a second opinion? |
Yup, that would be nice. I'm not very comfortable yet reviewing Lua. |
Looks good. Why did you use popen instead of execute for the logger? I'd use execute as it does not create a file handle in memory or at least directly closes it. Lua's garbage collection is not very clever and it might be possible that the file handle is only getting freed on garbage collection or program termination, but I'm not sure as you don't assign it to a variable at all... Just to be sure I'd use execute. This is still pedantic, as file handles don't really hurt. Your code is fine. Edit: I'm curious... When does it happen that the PIDs don't match? |
Hello @CodeFetch, thanks for your feedback. About the logging: Robin and I are not very familiar with Lua. When we first started this little project, we expected Lua to have some command or package to write to the syslog. But we couldn't find anything in other gluon packages. So we just used the first best command we knew. About edit(1): We don't know what the idea behind this is. We just ported the old (b)ash script to Lua as we were told (b)ash scripts wouldn't be accepted in Gluon anymore. About edit(2): Okay, we'll stay with popen for now. Best, |
local uci = require('simple-uci').cursor() | ||
|
||
function restart_tunneldigger() | ||
io.popen('logger -t tunneldigger-watchdog "Restarting Tunneldigger."') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't parse any return values we might use os.execute
here as well, no?
works as expected on 841: After killing the tunneldigger process, the checkscript detected and made a new tunnel. |
Squashed and merged with minor changes in 8e17635. Thanks for your work! |
package.
The logic is based on the former watchdog written in (B)ash.
The code was written by Robin Weiligmann admin@robwei.me and me.