-
-
Notifications
You must be signed in to change notification settings - Fork 579
An option in settings.json to specify a path to a script or exe that will be executed when application shuts down #186
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
Comments
This can be accomplished using "NirCmd" utility: This tool has "exec" and "waitprocess" commands with which you can accomplish this task, see: For example, something like this should work: Step 1: execute the shutdown.php script in background when your application starts (e.g. in index.php only when session starts) exec('"C:/path/to/nircmd.exe" exec "C:/path/to/phpdesktop/php/php.exe" "C:/path/to/phpdesktop/www/shutdown.php"'); Step 2: the shutdown.php script will wait for phpdesktop.exe process until it terminates set_time_limit(0);
exec('"C:/path/to/nircmd.exe" waitprocess "C:/path/to/phpdesktop/phpdesktop.exe");
# Now execute PHP code that should run when app terminates
.... |
If someone would like to create an example for phpdesktop with the code in post above then pull requests are welcome. |
hi @cztomczak i've made a laravel example based on the above to connect/disconnect mariadb on app start & shutdown but i have a couple of issues
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
// ...
/*
|--------------------------------------------------------------------------
| phpdesktop auto start/shutdown db
|--------------------------------------------------------------------------
*/
// start
require_once(__DIR__.'/db-start.php');
// shutdown
require_once(__DIR__.'/db-stop.php');
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
// ...
<?php
$nircmd = 'C:/Users/loko/Desktop/phpdesktop/_pkgs/nircmd/nircmd.exe';
$mariadb_start = 'C:/Users/loko/Desktop/phpdesktop/_pkgs/db/bin/mysqld.exe --console --skip-grant-tables';
exec("$nircmd exec hide $mariadb_start");
<?php
<?php
set_time_limit(0);
// wait for dt to close
$nircmd = 'C:/Users/loko/Desktop/phpdesktop/_pkgs/nircmd/nircmd.exe';
$desktop = 'C:/Users/loko/Desktop/phpdesktop/phpdesktop.exe';
exec("$nircmd waitprocess $desktop");
// now execute any code that should run when app terminates
$mariadb_stop = 'C:/Users/loko/Desktop/phpdesktop/_pkgs/db/bin/mysqladmin.exe shutdown';
exec("$nircmd exec hide $mariadb_stop"); the issues i have
not sure if am missing something, so any help is appreciated |
update i think i've found the reason, what happens is that any process that runs through |
@ctf0 hi, have you fix it? Can you provider a example ? |
@Hanson sadly no 😢 |
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. |
Script could be .bat or a .php file. In case of php use the existing php interpreter specified in settings.json. This option could be named "execute_on_shutdown".
See also a similar issue #163 for a new option named "execute_on_startup".
The text was updated successfully, but these errors were encountered: