Comments (8)
Hi,
Thanks for the interest in this extension.
Can you describe your work environment ?
PHP version ?
PHP X64 or X86 ?
PHP NTS or TS ?
When you run the script for add the new service have you open the command line windows with administrator's privileges ?
from win32service.
yeah, i have administrator's privileges. thanks for you Answer.
php7.0.29
PHP X86
PHP TS
i create environment from wampserver3.1.3_x86.exe
- i can't make service from other params, example : 'params' => '"' . DIR.'\c.php'. '" run',
2.when i create it and run it suceess, then, i do some steps testing something.
example : delete 1.txt>stop service> start service>service run success>but can't find 1.txt in my "D:\wamp\www\test" dir.
i do these steps many times, but can't touch 1.txt.(i did't change any code in service.php after when i run cmd "php service.php create start", because if i do that, then i can't run success the service, maybe service has strict regulations,they can find if i do something change then did't allow start the service)
service_20180529.log
from win32service.
Hi,
The goal of the service.php
example is show how to manage the service in one object in one PHP File.
You can copy-it and customize this file for your tasks. For this, copy it in you project and put you custom code in the function main_loop
.
Caution, the time of execution in main_loop
function is limited to 30 seconds. This limit is set by windows service manager for ask to the service her current state.
After writing the code, register the service with this command: php service.php create
and start the service with the Windows Service Manager or this command: netstat <service_name>
.
In you case, you want run another script in service. This script must execute the infinite loop like this function.
from win32service.
Look this example code: https://github.com/InExtenso/win32service/blob/less_admin/examples/sample.php
It is the minimum code for use this extension.
from win32service.
Yeah, at example above, i'm copy 'win32service/examples/service.php' and customize it.
service.zip
from win32service.
In your screenshot, the "params" is set to the file "c.php" this file is used for run the service.
The c.php
file has the main loop for service and change the service state seem the run()
function present in the service.php
?
Replace the param
value by '"'.__FILE__'" run'
. Remove the current service, re-create and start-it.
Edit: Please, paste you code into the comment ;-)
from win32service.
yeah,i upload my code in previous comment(service.zip).
I have no main loop and I can't do it.
I want to build one service excute php script instead of Command Line Interface excute php script.
It's could excute the php script when i start the service.(example: touch 1.txt or do something).
It's could i do it?
2.when i create it and run it suceess, then, i do some steps testing something.(Replace the param value by '"'.FILE'" run')
example : create service>start service>delete 1.txt>stop service> start service>service run success>but can't find 1.txt in my "D:\wamp\www\test" dir. (For this, i want to excute the php script when i start the service.(example: touch 1.txt))
i do these steps many times, but can't touch 1.txt.(i did't change any code in service.php after when i run cmd "php service.php create start", because if i do that, then i can't run success the service, maybe service has strict regulations,they can find if i do something change then did't allow start the service)
from win32service.
I have written another example based on service.php
file:
examples.zip
I have move the technical code into the abstract class AbstractWinServiceManager
for more clearity.
Read the service.php
file and custom it if you want. But caution to the $service['service']['service']
value. This is the Windows Service Manager identity. It'is used for manage and run the service. Must don't change between management and execution workspace.
Hopefully it can help you.
from win32service.
Related Issues (20)
- Pre-work the upgrade for PHP 8 HOT 4
- Characters encoding problems HOT 2
- Compilation for PHP7.4 in VC15 ? HOT 1
- 0.4.2 required for 7.4 - but labeled as "not for production" HOT 2
- Usage of win32_set_service_exit_code and win32_set_service_exit_mode HOT 7
- Use ValueError when function argument value is wrong
- Throw Exception if function return an error
- Remove specific code for older Windows version
- All example not work with V1
- Access Denied HOT 5
- Can't use in embed sapi HOT 3
- AppVeyor x86 build fail HOT 1
- Interact with Win32Services in a browser: ServiceAccessDeniedException HOT 4
- Missing win32 binaries on Github releases page HOT 3
- Access denied on service registration HOT 2
- New release supporting php 8.2 HOT 2
- Strange behavior on "pause" HOT 2
- PHP 8.2 support HOT 2
- Ability to define the 'dwControlsAccepted' parameter during service installation HOT 1
- PHP 8.3 support HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from win32service.