# Ensuring live recording output completes when shutting down the server

**URL:** <https://community.wowza.com/t/ensuring-live-recording-output-completes-when-shutting-down-the-server/45622>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [July 23, 2015, 1:07pm UTC](https://community.wowza.com/t/ensuring-live-recording-output-completes-when-shutting-down-the-server/45622 "2015-07-23T13:07:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_Lee](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@Eric\_Lee](https://community.wowza.com/u/Eric_Lee)\
**Post date:** [July 23, 2015, 1:07pm UTC](https://community.wowza.com/t/ensuring-live-recording-output-completes-when-shutting-down-the-server/45622/1 "2015-07-23T13:07:16Z")

</div>

Hi there,

I am currently writing a server side module to do live recording. When I shutdown the server in the middle of a live recording, the last “segment” of the live recording is incomplete (the .tmp file remains).

Is there a way to ensure that the last segment recorded can finish writing to file properly so that it is playable?

By shutdown of the server, I mean stopping the eclipse debugger, or closing the “console” window if I used the startup.bat in the [install-dir]/bin folder.

I was looking at calling vhost.getLiveStreamRecordManager().stopRecording(appInstance);

in the onServerShutdownStart(IServer) or onServerShutdownComplete(IServer) event listeners for IServerNotify3 to ensure the recording is stopped before shutdown. Would this work? If so, how could I get reference to the appInstance and vhost from the IServerNotify3 event listeners?

Thank you very much,

Eric

---

<div class="post-metadata">

**Author:** ![Michelle\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/michelle_b/32/394_2.png) [@Michelle\_B](https://community.wowza.com/u/Michelle_B)\
**Post date:** [July 29, 2015, 3:45pm UTC](https://community.wowza.com/t/ensuring-live-recording-output-completes-when-shutting-down-the-server/45622/2 "2015-07-29T15:45:15Z")

</div>

Hi Eric,

You can look into using the [IMediaWriterActionNotify](https://www.wowza.com/docs/how-to-use-imediawriteractionnotify-to-programmatically-move-and-rename-recordings-of-live-streams) listener interface to be notified when the recording is completed. You can then call the method to shutdown the server.

I hope that helps!

Michelle
