ilovetux / pyservice Goto Github PK
View Code? Open in Web Editor NEWThis project forked from photonios/pyservice
Cross-platform service library, turn your Python script into a service!
License: GNU General Public License v2.0
This project forked from photonios/pyservice
Cross-platform service library, turn your Python script into a service!
License: GNU General Public License v2.0
We need an entire test suite so we can get some pretty badges from Travis CI and appveyor.
We will need a setup.py
file if we wish to get this up on PyPI and it will also help with running the tests.
We need some examples to include in the readme.
Now that we are implementing sphinx docs, unittests and integrating with more standard Python toolsets, it will make things easier to take advantage of the work that github has done in building this robust .gitignore
file
There are currently three custom exceptions, all of which could be replaced with RuntimeError
. This will be the first step in cleanup.
Now that everything is working (more or less) we need to make the Linux CLI offer some of the same options as the windows CLI, most notably
As __init__
is for initialization, it would make more sense to have a second method for handling cli arguments and calling the correct methods, this would make our API more verbose, but it would also make testing easier as we can instanciate, mock and test in separate steps.
While I'm at it, I will modify the argument handling to use Python's argparse module so we can later expand the CLI to accept arguments from the user for different options.
When running on Linux, service.py attempts to from .windows import PyServiceWindows
on Linux this will fail because pywin32 will not be installed. I propose to import PyServiceWindows
or PyServiceLinux
as PlatformService
. This will allow us to simplify PyService.__init__
as well as we will not need to create a platform_map
.
We need some good documentation which we can host on readthedocs.
The formatting of the init script is off as there is a lot of indentation
I have fixed the install issue, but when starting the service, it runs but it is stuck in the "starting" state. This is because we need to report the service status. I've been wrestling with this all night...trying again now with fresh eyes.
python test_linux_daemon.py --install
The first place a potential user will look is in the readme. This project lacks one. This will be the second phase of the cleanup effort.
This will be ongoing as I need to dive deeper and gain more insight into how it all works together.
Trying to make everything work on Windows has taken a huge portion of my time and has led me to learn way too much (and too little) about the pywin32 project. What I propose is to create a factory function which takes a function function and returns a class. This class will be constructed based on the current platform.
Come to think of it, this sounds a lot like a decorator. I'm going to try that and see what happens.
It doesn't look as good, but it does work in both 2 and 3.
I have tested this on Fedora 24 and it works, but because we use an init.d (ie sys v init) script, the system needs to be rebooted before you can control it with systemctl. This is because the stsemd-sysv-generator needs to run on boot. The other option is to tell systemd to reload, ie systemctl daemon-reload
.
We need to drop privileges as soon as we are done with them. This is a standard practice to reduce security concerns. It is ok to require administrative privileges to start/stop/install/uninstall but as soon as you no longer need the privileges you should drop them.
The original author licensed this under the GPL 2, I wish to move that up to the GPL 3. I will make the changes with the assumption that if the author disagrees I can change it back.
So, we have everything working except when I use the tornado example (modified for the new API) it installs/starts/removes just fine, but hangs on stopping. I hope I can fix this using something in the tornado API because I've found the win32serviceutils api to be a pain. I'm sure that this is due to windows and not the pywin32 package. I basically need a way to tell tornado to stop when a flag variable is set.
PyService carries around a reference to the platform specific implementation, this is inefficient and we could drastically simplify the code if it simply inherited from PlatformService
instead.
We are creating the cross-platform public API in PyService, but all action methods are prefixed with an underscore while the platform specific classes are not prefixed with an underscore. To make it more sensible to newcomers, we should make the platform specific methods private (ie. prefixed with an underscore) and the public API public (ie not prefixed with an underscore).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.