-
-
Notifications
You must be signed in to change notification settings - Fork 576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A way to launch external processes/servers during startup or later, and automatic shutdown of these processes when app exits #163
Comments
It is possible to close external processes currently, but only with some additional .bat script and WMI queries. This has been explained here: https://groups.google.com/d/msg/phpdesktop/PLC0dMz0Pp8/6kCC_VNTP_wJ Such .bat script would check whether phpdesktop.exe process still runs and when it's not running anymore it could end external processes launched by php's system() command. It's a bit complicated, but feasible. Your app's processes names shold be unique to make it reliable. Original comment by |
Related: Issue #186 ("An option in settings.json to specify a path to a script or exe that will be executed when application shuts down"). |
Somebody knows something about this feature? Is this planned to be implemented or already does? |
There is no known schedule for implementing this feature. |
This functionality can be accomplished using NirCmd command-line utility, see:
|
Another option is to use a script (Autohotkey or AutoIt etc) to create an app launcher. ApplicationFolder Contents of AppLauncher.ahk
|
A solution that worked for me is to set the port on "listen_on" option dynamically, in the first page of the app run a ".bat" file that close all process that I created before, in my case python.exe process. After this, create the process that you need. But this only works to prevent crash on re-open. Not kill all the process after close. Sorry for my bad english. |
I have pull example how to create Windows Print Service on start up and on shutdown application just feel free to take a look #305 maybe it's help you to know how it's work for me. I forgot to write settings.json value |
User can execute applications using php's system() command or similar, but there is no easy way to end long running processes when phpdesktop application closes.
Option 1 - "execute_on_startup" in settings.json
User wants to run node.js server along with phpdesktop. That server should start when phpdesktop starts and shut down automatically when phpdesktop app exits.
Solution: In settings.json add option "execute_on_startup" which would be a list of .exe, allowed would be relative paths (phpdesktop dir) or full paths.
There is also an idea for "execute_on_shutdown" option, see Issue #186.
Option 2 - new JS API: phpdesktop.LaunchProcess()
While app runs user wants to run an external process. Currently this can be done using XMLHttpRequest to a php script that calls php's system() command or similar. Unfortunately there is no easy way to end this process when phpdesktop app exits. For example this process runs a long task, but user exits application early, so this process should be killed automatically.
Solution: Add new function to JavascriptApi: LaunchProcess(). It should have some options whether the app window should be hidden. Use the ShellExecuteEx function and save process handle (SHELLEXECUTEINFO.hProcess) for later to end the process when app exits.
ShellExecuteEx:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762154(v=vs.85).aspx
SHELLEXECUTEINFO:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).aspx
Original issue reported on code.google.com by
[email protected]
on 7 Mar 2015 at 8:34The text was updated successfully, but these errors were encountered: