Automatically starting btmon in Windows after reboot

Discuss anything which doesn't fall into the other categories here.
Post Reply
BobM
Posts: 21
Joined: Fri Dec 07, 2012 3:18 pm

Automatically starting btmon in Windows after reboot

Post by BobM » Fri Jan 04, 2013 4:23 pm

Hi,

After some initial experimentation with my new GEM, btmon, and storing to MySQL and uploading to OpenEnergyMonitor using a laptop, I wanted to move btmon to our desktop computer which can be always on so btmon is always up and doing its thing. However, I wanted to have btmon automatically re-started anytime my desktop gets rebooted. My desktop is a Windows XP box and I thought I'd pass along what I did to get things working the way I wanted. I imagine there is a simpler solution but this is what seems to work for me until I get around to any fine tuning.

I created a ScheduledTask in Windows (Start->All Programs->Accessories->System Tools->ScheduledTasks) scheduled to run at boot time. I assigned the task to an account with Administrator privilege. Since, I presumed there would be no console window when the task started I used pythonw.exe to run the script whose name I changed to btmon.pyw. I also added python code to ignore MySQL warnings - no console. In the advanced properties for the scheduled task I specified the command line to run btmon w/ arguments. At this point in the process I discovered that after a boot I did not see pythonw running but I could execute the task just fine after I logged into an account. I finally discovered that btmon was being started before the MySQL service was ready for connections. So, I modified btmon in the Monitor class' run method where it calls p.setup() for each packet processor. I simply changed it so that if the setup caused an exception to sleep for 10 seconds and try again for that processor. That worked fine. I know this is a hack but until I come up with something better it seems to work.

Hope it helps
mattm55
Posts: 62
Joined: Fri Oct 08, 2010 8:23 am

Re: Automatically starting btmon in Windows after reboot

Post by mattm55 » Tue Feb 12, 2013 8:44 am

Hello Bob,

I use the free version of r2 Studios "Startup Delayer" for my sever restarts. That way I can auto start, in sequence, my apps as needed.

It's fairly easy to setup (GUI) and works well for my server. Then I created a couple of .bat files to startup the btmon scripts using collect.cfg(MySQL)/upload.cfg(SEG).

Just my .02

Thanks, Matt
BobM
Posts: 21
Joined: Fri Dec 07, 2012 3:18 pm

Re: Automatically starting btmon in Windows after reboot

Post by BobM » Sun Feb 17, 2013 7:52 pm

mattm55 wrote:Hello Bob,

I use the free version of r2 Studios "Startup Delayer" for my sever restarts. That way I can auto start, in sequence, my apps as needed.

It's fairly easy to setup (GUI) and works well for my server. Then I created a couple of .bat files to startup the btmon scripts using collect.cfg(MySQL)/upload.cfg(SEG).

Just my .02

Thanks, Matt
Thanks Matt. Does this work for apps that startup before log in? Our XP desktop has multiple accounts and there is no automatic log in after boot up. The r2 site says it's after log in but perhaps that is not meant to be interpreted literally?
mattm55
Posts: 62
Joined: Fri Oct 08, 2010 8:23 am

Re: Automatically starting btmon in Windows after reboot

Post by mattm55 » Mon Feb 18, 2013 2:01 pm

BobM wrote:
Thanks Matt. Does this work for apps that startup before log in? Our XP desktop has multiple accounts and there is no automatic log in after boot up. The r2 site says it's after log in but perhaps that is not meant to be interpreted literally?
Hmm, I believe it needs to be logged in to startup. I have a dedicated machine which bypasses the login so not sure if it would work. Mines running Win7 32bit.

Matt
BobM
Posts: 21
Joined: Fri Dec 07, 2012 3:18 pm

Re: Automatically starting btmon in Windows after reboot

Post by BobM » Mon Feb 18, 2013 3:47 pm

mattm55 wrote:
BobM wrote:
Thanks Matt. Does this work for apps that startup before log in? Our XP desktop has multiple accounts and there is no automatic log in after boot up. The r2 site says it's after log in but perhaps that is not meant to be interpreted literally?
Hmm, I believe it needs to be logged in to startup. I have a dedicated machine which bypasses the login so not sure if it would work. Mines running Win7 32bit.

Matt
The way I have things set up no log in is needed to start btmon just had to modify btmon to account for the possibility that mysql was not ready when btmon started. Btmon just keeps trying until mysql is ready. Whatever works. Thanks.
Post Reply