question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Host Level Event Support

See original GitHub issue

Consider adding the ability for user code to be triggered on various host level events, e.g. Startup/Shutdown. Here is a case from SO where the user would like to perform a flush operation on static data: https://stackoverflow.com/questions/36760241/intercept-azure-function-host-shutdown-flush-application-insights-telemetryclie. This would also provide a mechanism for users to write Function App initialization code - i.e. startup time logic that only needs to be run once in an app domain.

We could introduce a new Functions specific trigger that triggers on system events. Users can then write a function for these and handle as is - no new mechanism for running user code is needed. This is similar in spirit to the ErrorTrigger extension I wrote (sample code here). However for functions we might want to generalize that more so its not just errors. Perhaps rather than making this Functions specific, it can be a first class Extension, since the scenarios exist outside of Functions. We could allow people to write a trigger like [HostEventTrigger("Shutdown")] HostEvent event. This would facilitate existing scenarios as well. We could then expose this new extension in Functions.

Let’s see if more scenarios pop up requiring something like this, or if there are other better ways to solve these cases. Ideally we don’t really want users thinking in terms of the host - we want them to just focus on relatively short lived functions.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:8
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
quality-leftoverscommented, Apr 28, 2021

Also interested in this functionality. I know there are entity functions, but those do not fit every use case.

If no one can detect when the lifetime of a workload ends there can be no efficient flushing.

  • I like the idea of [HostEventTrigger(“Shutdown”)]
  • Since there already is FunctionsStartup maybe we could have a FunctionShutdown (that can consume services via DI)?
2reactions
grbsplttcommented, Jun 19, 2020

Any update to this, 4 years and counting? Looking for node support to setup DB connections at startup, no matter which function is called first. Right now the work around to support this is quite poor.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set event log security locally or via Group Policy
This article provides the methods to set event log security access rights.
Read more >
AD and LDS diagnostic event logging - Windows Server
5 (Internal): This level logs all events, including debug strings and configuration changes. A complete log of the service is recorded. Use this ......
Read more >
What Is a Windows Event Log? - IT Glossary
Windows event logging provides detailed information like source, username, computer, type of event, level, etc., which helps effectively diagnose and fix issues ...
Read more >
View System Event Log
Select a host in the vSphere Client navigator. Click Monitor tab, and click Hardware Health. Click SYSTEM EVENT LOG.
Read more >
Essential Windows Services: EventLog / Windows Event Log
The Windows Event Log (EventLog) service captures and manages events from background services, tasks and applications running on your PC.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found