SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Customizations
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Customizations This forums is for discussing and sharing user-created modifications for the SageTV application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss customizations for SageTV version 6 and earlier, or for the SageTV3 UI.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-24-2009, 09:18 PM
korben_dallas's Avatar
korben_dallas korben_dallas is offline
Sage Icon
 
Join Date: Oct 2004
Location: USA
Posts: 1,250
Lightbulb Plugin / Utility request: shutdown SageTV and execute a batch file

Ok developers,

I'll be one of you guys' bestest friends ever if you would make a small plugin / addon / utility that will gracefully shutdown SageTV and then execute a DOS batch file or other executeable.

1) On a schedule, this doesn't need to be too advanced
2) Checks to make sure SageTV isn't recording before shutdown
3) Checks to see how much time before next scheduled recording, with a minimum threshold in minutes before shutdown
4) If failure to shutdown due to 2 or 3, then try again in x number of minutes with y number of retries
5) Writes datetime to a simple logfile with shutdown success, failure, retry, last retry
__________________
SageTV server & client: Win 10 Pro x64, Intel DH67CF, Core i5 2405s, 8 GB ram, Intel HD 3000, 40GB SSD system, 4TB storage, 2x HD PVR component + optical audio, USB-UIRT 2 zones + remote hack, Logitech Harmony One, HDMI output to Sony receiver with native Intel bitstreaming
Reply With Quote
  #2  
Old 12-26-2009, 12:06 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Just out of curiosity (as it may help someone looking to do this for you anyways), but what functionality are you trying to get with this? It is possible it is something you could already do with existing tools. (Sage Job Queue comes to mind).
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #3  
Old 12-26-2009, 08:27 PM
CollinR CollinR is offline
Sage Icon
 
Join Date: Dec 2004
Location: Tulsa, OK
Posts: 1,305
Yup you can make this happen with SJQ.


Damn I need to reinstall it/upgrade. It's been too long.
Reply With Quote
  #4  
Old 12-27-2009, 03:33 AM
korben_dallas's Avatar
korben_dallas korben_dallas is offline
Sage Icon
 
Join Date: Oct 2004
Location: USA
Posts: 1,250
I need to do some once-a-week or perhaps once-a-night things to my SageTV server, but I obviously don't want the server shutting down services, processing, and rebooting while SageTV is in the middle of recording.

My understanding of SJQ is that SageTV is still running though? I need SageTV completely shut down. And, I don't want to miss a recording if, for example, my nightly server job runs at 3:30am and unbeknownce to me SageTV had something scheduled for 3:35am.

So it checks if SageTV is recording, or soon will be, and if not safely exits SageTV and runs the batch file / exe.
__________________
SageTV server & client: Win 10 Pro x64, Intel DH67CF, Core i5 2405s, 8 GB ram, Intel HD 3000, 40GB SSD system, 4TB storage, 2x HD PVR component + optical audio, USB-UIRT 2 zones + remote hack, Logitech Harmony One, HDMI output to Sony receiver with native Intel bitstreaming
Reply With Quote
  #5  
Old 12-27-2009, 05:43 AM
gplasky's Avatar
gplasky gplasky is offline
SageTVaholic
 
Join Date: Jul 2003
Location: Howell, MI
Posts: 9,203
Quote:
Originally Posted by korben_dallas View Post
I need to do some once-a-week or perhaps once-a-night things to my SageTV server, but I obviously don't want the server shutting down services, processing, and rebooting while SageTV is in the middle of recording.

My understanding of SJQ is that SageTV is still running though? I need SageTV completely shut down. And, I don't want to miss a recording if, for example, my nightly server job runs at 3:30am and unbeknownce to me SageTV had something scheduled for 3:35am.

So it checks if SageTV is recording, or soon will be, and if not safely exits SageTV and runs the batch file / exe.
So in SJQ you create a job looking for all the parameters you have described. If it meets those requirements it executes a batch job that will shut down Sage, perform the maintenance you want and the last task in the batch file will restart the server or Sage itself. It should work just fine for you.

Gerry
__________________
Big Gerr
_______
Server - WHS 2011: Sage 7.1.9 - 1 x HD Prime and 2 x HDHomeRun - Intel Atom D525 1.6 GHz, Acer Easystore, RAM 4 GB, 4 x 2TB hotswap drives, 1 x 2TB USB ext Clients: 2 x PC Clients, 1 x HD300, 2 x HD-200, 1 x HD-100 DEV Client: Win 7 Ultimate 64 bit - AMD 64 x2 6000+, Gigabyte GA-MA790GP-DS4H MB, RAM 4GB, HD OS:500GB, DATA:1 x 500GB, Pace RGN STB.
Reply With Quote
  #6  
Old 12-27-2009, 08:20 AM
nyplayer nyplayer is offline
SageTVaholic
 
Join Date: Sep 2005
Posts: 4,997
This is my ruleset and batch file.

I use windows scheduler to create a file c:\controls\oktoreboot.txt every sunday at 4:00 am.

I have SJQ run this rule set anytime c:\controls\oktoreboot.txt exists.

Code:
//Ok To Reboot
if [FileExists == "c:\\controls\\oktoreboot.txt" && IsSomethingRecording == "false" && TranscodeQueueSize < "1" && TimeUntilNextRecording > "15M" && $.GetMediaTitle{} == "Not Recording" && TimeOfDay > "05:00" && TimeOfDay < "20:00"]{
    :PRIORITY 110
      OKTOREBOOT
}

This is my batch file it reboots the clients , Sage server and cleans up temp files.


Code:
del c:\controls\oktoreboot.txt
tskill wscript /a
cd c:\SageBatch
c:
process -q SageTV.exe
net stop SageTV

del "C:\Documents and Settings\All Users\Application Data\TEMP" /q

start shutdown -m \\sageclient -r -f -t 60
start shutdown -m \\nyplayer -r -f
start shutdown -r -f -t 2
exit 1
Also anytime I want to reboot sage I simply create c:\controls\oktoreboot.txt and sage will reboot at the next convenient time.
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct.

Last edited by nyplayer; 12-27-2009 at 08:24 AM.
Reply With Quote
  #7  
Old 12-27-2009, 08:24 AM
korben_dallas's Avatar
korben_dallas korben_dallas is offline
Sage Icon
 
Join Date: Oct 2004
Location: USA
Posts: 1,250
Is there a graceful way to exit SageTV programatically?

There's the exe message event {Power Off 44}, but as I recall that only minimizes SageTV to the taskbar?

I know that externally I can kill the SageTV.exe process, but that's not really graceful.. might introduce some problems in the SageTV files.
__________________
SageTV server & client: Win 10 Pro x64, Intel DH67CF, Core i5 2405s, 8 GB ram, Intel HD 3000, 40GB SSD system, 4TB storage, 2x HD PVR component + optical audio, USB-UIRT 2 zones + remote hack, Logitech Harmony One, HDMI output to Sony receiver with native Intel bitstreaming
Reply With Quote
  #8  
Old 12-27-2009, 08:27 AM
nyplayer nyplayer is offline
SageTVaholic
 
Join Date: Sep 2005
Posts: 4,997
I use a free program process.exe.

cd c:\SageBatch
c:
process -q SageTV.exe
net stop SageTV
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct.
Reply With Quote
  #9  
Old 12-27-2009, 11:50 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Sage ships with a command-line utility called SendMessage.exe that can be used to send a WM_CLOSE or WM_QUIT message to the running UI.

For the service, use net stop as nyplayer indicates.
__________________
-- Greg
Reply With Quote
  #10  
Old 03-06-2010, 12:30 AM
banshee banshee is offline
Sage User
 
Join Date: Jan 2009
Posts: 25
I am trying to get this shutdown script to work as well...totally new to SJQ...and am SOOO close. But I'm having a problem with the restart.

When the SJQ client batch file executes the restart, it does not complete. The restart begins, but then eventually I end up with a black screen and an arrow and the restart does not complete. I have to hit the power switch to reboot.

When I manually run the batch file from the command prompt, it works great...and completes as normal.

The only difference I an see is that when I run from the command prompt, the restart is initiated by Q6600\sage (my user name). When it is initiated from SJQ, the restart windows says the restart was initiated by NT AUTHORITY\SYSTEM.

Could that be the problem? Any suggestions how I can fix it?
Reply With Quote
  #11  
Old 04-27-2010, 06:27 AM
zzmystique's Avatar
zzmystique zzmystique is offline
Sage Advanced User
 
Join Date: May 2004
Location: New Zealand
Posts: 211
I'm trying to setup SJQ to restart sagetv during the night.
I use windows scheduler to create a file c:\controls\oktorestartsage.txt every night at 2:30 am.

Code:
//Ok To Reboot
if [FileExists == "c:\\controls\\oktoreboot.txt" && IsSomethingRecording == "false" && TranscodeQueueSize < "1" && TimeUntilNextRecording > "10M" && $.GetMediaTitle{} == "Not Recording" && TimeOfDay > "02:35" && TimeOfDay < "05:00"]{
    :PRIORITY 110
      OKTOREBOOT
}
but it never runs even though I think that all the conditions are met, not sure about $.GetMediaTitle{} == "Not Recording". Is there an alternative to using $.GetMediaTitle{} == "Not Recording", does this work with snapshot version SJQ v3.0.2.792?

Any idea's why it's not working?
__________________
ZZMystique
My setup: Server: SageTV v7, Intel i5, 8GB, 180GB SSD, 4TB HDD, Win7HP & (DVB Viewer Pro with DVB Viewer for SageTV using 2xTBS6281 DVB-T2).
Reply With Quote
  #12  
Old 04-27-2010, 07:00 AM
nyplayer nyplayer is offline
SageTVaholic
 
Join Date: Sep 2005
Posts: 4,997
I used Videoredo to cut a recording(a few meg) and then I put it in the import folder then I used the webserver to name it Not Recording. You can use any title that you have just archive it and keep it around... I just got creative :-) for example && $.GetMediaTitle{} == "Double Jeopardy"
__________________
Channels DVR UBUNTU Server 2 Primes 3 Connects TVE SageTV Docker with input from Channels DVR XMLTV and M3U VIA Opendct.

Last edited by nyplayer; 04-27-2010 at 07:03 AM.
Reply With Quote
  #13  
Old 04-27-2010, 09:25 PM
zzmystique's Avatar
zzmystique zzmystique is offline
Sage Advanced User
 
Join Date: May 2004
Location: New Zealand
Posts: 211
Quote:
Originally Posted by nyplayer View Post
I used Videoredo to cut a recording(a few meg) and then I put it in the import folder then I used the webserver to name it Not Recording. You can use any title that you have just archive it and keep it around... I just got creative :-) for example && $.GetMediaTitle{} == "Double Jeopardy"
That makes sense, will give it a try. Are there any other gotcha's that will cause the batch file to not complete?
__________________
ZZMystique
My setup: Server: SageTV v7, Intel i5, 8GB, 180GB SSD, 4TB HDD, Win7HP & (DVB Viewer Pro with DVB Viewer for SageTV using 2xTBS6281 DVB-T2).
Reply With Quote
  #14  
Old 05-03-2010, 05:44 AM
zzmystique's Avatar
zzmystique zzmystique is offline
Sage Advanced User
 
Join Date: May 2004
Location: New Zealand
Posts: 211
Have the restart sage and reboot SJQ rules working now , it is working well.

Took me a little while to realise that the SJQ Task Client could not be stopped during the restart or reboot process otherwise the scripts would not complete.

Cheers
__________________
ZZMystique
My setup: Server: SageTV v7, Intel i5, 8GB, 180GB SSD, 4TB HDD, Win7HP & (DVB Viewer Pro with DVB Viewer for SageTV using 2xTBS6281 DVB-T2).
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Utility: Batch Metadata Importer 3.x stuckless Batch Metadata Tools 2416 09-20-2011 08:03 PM
Execute a batch file after an error? eric3a SageTV Customizations 0 08-12-2009 09:37 PM
Batch file to shutdown Sage (not sleep) pknowles SageTV Software 1 11-16-2007 03:37 PM
Feature Request: "Copy file" for Sage Conversion utility pawn SageTV Software 5 07-10-2007 05:36 PM
hs_err_pid log file from an exepected SageTV 1.4 shutdown carlgar SageTV Software 0 05-22-2004 11:02 PM


All times are GMT -6. The time now is 05:52 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.