Code Monkey home page Code Monkey logo

Comments (8)

macintoshplus avatar macintoshplus commented on June 15, 2024

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.

lovekobeme avatar lovekobeme commented on June 15, 2024

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

  1. i can't make service from other params, example : 'params' => '"' . DIR.'\c.php'. '" run',
    qq 20180529081842
    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)
    qq 20180529084015
    qq 20180529084240
    service_20180529.log

from win32service.

macintoshplus avatar macintoshplus commented on June 15, 2024

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.

macintoshplus avatar macintoshplus commented on June 15, 2024

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.

lovekobeme avatar lovekobeme commented on June 15, 2024

Yeah, at example above, i'm copy 'win32service/examples/service.php' and customize it.
service.zip
qq20180529183814

from win32service.

macintoshplus avatar macintoshplus commented on June 15, 2024

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.

lovekobeme avatar lovekobeme commented on June 15, 2024

yeah,i upload my code in previous comment(service.zip).
I have no main loop and I can't do it.
qq 20180530111827
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)
qq 20180529084015
qq 20180529084240

from win32service.

macintoshplus avatar macintoshplus commented on June 15, 2024

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.

image

Hopefully it can help you.

from win32service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.