Reminder to halt VM?
I have a Linux VM on a Windows 10 host. I only use it when working on my PHPStorm projects, which is not an everyday thing. Sometimes I close PHPStorm, go on to working on unrelated tasks, and completely forget about my VM. Not only is that a waste of memory when I'm not using it, but if I shut down Windows I risk breaking the VM - that hasn't happened yet, but... (I know the idea of vagrant and provisioners is that it's no big deal to recreate a VM, but not all my customizations are in the provisioning files, due to my lack of knowledge of how to do that.)
So, is there a way in PHPStorm to attach something to the close event (I don't care if it's closing of the software overall or a project) to either halt the VM or remind me that it's still running?
请先登录再写评论。
Hi there,
I personally do not know such solution.
Anyway, some tickets to watch after:
P.S. The only thing that comes into my mind right now: have some batch/PowerShell script that will be launched by scheduler (e.g. every 5 mins or so) that will check if there is any PhpStorm process running .. and if not -- attempt to shutdown the VM. Nuance: do not launch actual shutdown code if VM is not running.
Downside is obvious: what if you just restarting IDE .. or temporarily close it etc -- no way to read your mind/intentions.
(just in case: startup tasks are already possible.)
Thanks. Yeah, those tickets are applicable, and I just now voted for them.
That scheduled script sounds like a reasonable idea. I don't need it to actually do the shutdown - it would be sufficient to just alert me that PhpStorm is not running but the VM is. But that sounds like pretty advanced scripting - if it were Linux I might have a hope of figuring out how to write a little cron-run bash script, but Windows under-the-hood stuff is pretty opaque to me. Maybe someday...
PowerShell script would be the best solution here. It's not super hard .. but yes, you would need to spend a bit of time to get into the syntax (as it's differs / unusual at first glance).
General idea is:
Some links:
P.S. Instead of enumerating running processes you may just look up at what "C:\Users\USERNAME\.PhpStorm2018.1\config\port.lock" file is (the file size). If it's 0 bytes -- IDE is not running; otherwise -- it's running. NOTE: if IDE process is killed in any way (actual kill; crash; hard reboot/power loss) the file most likely still be non-zero length.
Pros:
Cons: