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
Automatically starting btmon in Windows after reboot
-
- Posts: 21
- Joined: Fri Dec 07, 2012 3:18 pm
-
- Posts: 62
- Joined: Fri Oct 08, 2010 8:23 am
Re: Automatically starting btmon in Windows after reboot
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
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
-
- Posts: 21
- Joined: Fri Dec 07, 2012 3:18 pm
Re: Automatically starting btmon in Windows after reboot
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 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
-
- Posts: 62
- Joined: Fri Oct 08, 2010 8:23 am
Re: Automatically starting btmon in Windows after reboot
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.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?
Matt
-
- Posts: 21
- Joined: Fri Dec 07, 2012 3:18 pm
Re: Automatically starting btmon in Windows after reboot
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.mattm55 wrote: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.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?
Matt