Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Service and Periodic execution of ping #89

Merged
merged 5 commits into from May 21, 2019

Conversation

a-martynovich
Copy link
Contributor

@a-martynovich a-martynovich commented May 20, 2019

Closes #35
The new Executor allows to schedule periodic or one-shot execution of a function in separate process. An arbitrary number of functions can be scheduled, but only MAX_WORKERS processes will be spawned, which is the max number of simultaneously executed functions while others are waiting.

If a function crashes it won't destroy the main process. All function's stdout/stderr is attached to the main process. If a function hangs longer than the specified timeout its process gets killed. All spawned processes are destroyed at main process exit.

A function can be scheduled at any time. It is also possible to stop periodic execution of a single function.

@cla-bot cla-bot bot added the cla-signed label May 20, 2019
Add important comment to Executor
@a-martynovich
Copy link
Contributor Author

@vpetersson This PR is ready for merge.
A note: if an older version of agent (< 0.1.4.9 ) was installed on the device the newer agent won't start automatically after installation. It will start either after a reboot or if you do apt purge wott-agent before installing 0.1.5.0.

@vpetersson vpetersson requested a review from rptrchv May 21, 2019 10:48
@vpetersson
Copy link
Contributor

@a-martynovich noted on the older versions - that's fine in this stage. How do we control the granularity of the periodic runs and how are they run right now?

@a-martynovich
Copy link
Contributor Author

@vpetersson

agent/agent/__main__.py

Lines 51 to 59 in 61ccadf

PING_INTERVAL = 60 * 60
PING_TIMEOUT = 10 * 60
def run_daemon(debug, dev):
exe = executor.Executor(PING_INTERVAL, run, (True, debug, dev),
timeout=PING_TIMEOUT, debug=debug)
executor.schedule(exe)
executor.spin()

Here’s how ping is run right now. Hopefully this code speaks for itself.

@vpetersson
Copy link
Contributor

Got it - yep. So i guess what we need to do is to start breaking ping apart and classify how often various operations should run.

agent/executor.py Outdated Show resolved Hide resolved
@rptrchv
Copy link
Contributor

rptrchv commented May 21, 2019

@a-martynovich is is possible to test your new code?

@a-martynovich
Copy link
Contributor Author

@rptrchv Manually for now. Proper automated testing for this will take a lot of time to code.

@rptrchv
Copy link
Contributor

rptrchv commented May 21, 2019

lgtm

@vpetersson vpetersson merged commit 17c3e96 into WoTTsecurity:master May 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants