Massimo
Usage: 'service.py [options] install|update|remove|start
[...]|stop|restart [...]|debug [...]'
Options for 'install' and 'update' commands only:
--username domain\username : The Username the service is to run under
--password password : The password for the username
--startup [manual|auto|disabled] : How the service starts, default = manual
--interactive : Allow the service to interact with the desktop.
--perfmonini file: .ini file to use for registering performance monitor data
--perfmondll file: .dll file to use when querying the service for
performance data, default = perfmondata.dll
Options for 'start' and 'stop' commands only:
--wait seconds: Wait for the service to actually start or stop.
If you specify --wait with the 'stop' option, the service
and all dependent services will be stopped, each waiting
the specified period.
So I suggest that the startup parameters of web2py can be saved in an
ini file, so we can write a wrap of service and invoke web2py server.
So this ini file can be read by this wrap program or web2py itself.
Which one is better? I would like the later. And we will have two ways
to get the startup arguments: 1) from ini 2)from command line
And we can read ini first, then if there are command line options, we
can use them to overwrite the ini options.
But for now, we may found that there are different action according the options:
1) command line mode
2) GUI mode
3) Shell mode
4) execute program in an app environment
5) service mode
So if we need an action parameter in the command line? Just like:
web2py [options] start
web2py [options] gui
web2py [options] shell
web2py [options] execute
web2py [options] service
I didn't think very clearly, how about others opinions?
--
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
meide <<wxPython UI module>>: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou
Massimo
1. Working path is not correct, when I start the server, the path is
in lib/site-package/win32, so I had to get the real web2py path from
register.
2. I'm working on python 2.4, and if I use http://localhost:8000 I'll
get an error, it'll say that Admin is disabled because unsecure
channel, and I check the code:
if remote_addr not in (http_host, socket.gethostname()):
raise HTTP(200,'Admin is disabled because unsecure channel')
and I found 127.0.0.1 is not be treated the same as localhost
and before I found this problem, I also found that:
except BaseException, exception:
because I'm using python 2.4 version, so there is no BaseException
defined(main.py 260), so the admin will raise an ticket, and when I
click it, it'll raise a new one, so the ticket will fall into infinite
loop, and also BaseException in restricted.py 63. And If I removed
BaseException, so I found exception is not right at all, maybe it's a
typo?
python WindowsService.py install
python WindowsService.py start
Massimo
We need a more general strategy (interface) to configure and setup
web2py as service cross-platform, including HTTPS.
Does anybody has a script to setup a service under OSX and/or Linux?
Massimo
1. Modifed main.py and restricted.py, change BaseException, exception
to Exception
2. Add service.py, so you can :
python service.py install
python service.py start
python service.py stop
3. add options.py, and save command line options in the model, it's
very easy to change
4. try to find working path in register with:
try:
import _winreg
h = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
r'SYSTEM\CurrentControlSet\Services\web2py')
cls = _winreg.QueryValue(h, 'PythonClass')
dir = os.path.dirname(cls)
os.chdir(dir)
except:
self.log("Cann't change to web2py working path, server is stopped")
return
and here "web2py" is define in _svc_name_ of Web2pyService class.
And another question:
in admin/default.py controller:
http_host = request.env.http_host.split(':')[0]
remote_addr = request.env.remote_addr
if remote_addr not in (http_host, socket.gethostname()):
raise HTTP(200,'Admin is disabled because unsecure channel')
and If I use "localhost" it'll raise the exception. So how to support localhost?
check in trunk. I renamed your service to gluon/winservice.py and now
you can use it as
python web2py.py -W install/start/stop
and once compiled
web2py.exe -W install/start/stop
Could you please try? I do not have windows today.
I would like a way to specify the name of the options file so that it
is used by widget if not running as service.
web2py.py -L options.py
would you be able to add that? Do not use import, use exec('import')
as in winservice otherwise it messes up py2exe and py2app.
No idea about the localhost issue.
Massimo
> <service.diff>
python web2py.py -W install [-L options]
python web2py.py -W start [-L options]
python web2py.py -W stop
You can specify -L when install or start windows service, and if you
start service with -L option, it'll install the service again, then
start the service.
Default config file is options.py
4. Add option_std.py as a template
your corrections are in trunk but:
this has to stay because without try... except it may break on linux/osx
-try:
- from gluon.winservice import web2py_windows_service_handler
-except: pass
"web2py" should not be capitalized. The name is always lower case.
I am not sure what this does
path = os.path.dirname(__file__)
when running the binary versions. We need to try it. What is
classtring for? Does it need to be path dependent?
Does winservice.py makes any sense without an installer? I think we
need a windows installer that installs web2py, ulipad, a hook to the
shell, two services (80, 443) and packages a nice windows menu to
run this all.
Massimo
> <service.diff>
Just for testing.
>
> "web2py" should not be capitalized. The name is always lower case.
>
> I am not sure what this does
>
> path = os.path.dirname(__file__)
>
> when running the binary versions. We need to try it. What is
> classtring for? Does it need to be path dependent?
I don't know if the binary can be used. Because PythonService.exe will
register python class, so if you use binary, I don't know how to let
PythonService.exe to get the python class. And for __file__, I just
want to know the service class's file path, so I can set the right
serviceClassString. Because if you invoke
win32serviceutil.HandleCommandLine via importing the module, the class
path will be like:
gluon.winservice.Web2pyService
So you can see it's not a absolute path, and PythonService.exe will
not get the right class because the directory is not right, it'll be
lib/site-packages/win32, so I process __file__ just want to ensure the
serviceClassString can be absolute path.
> Does it need to be path dependent?
I think so. Of cause just according my testing.
>
> Does winservice.py makes any sense without an installer? I think we
> need a windows installer that installs web2py, ulipad, a hook to the
> shell, two services (80, 443) and packages a nice windows menu to
> run this all.
>
I have no idea about it know. Because I often use source version, and
it'll be easy to implement what you want.
Thank you Limodou.
your corrections are in trunk but:
this has to stay because without try... except it may break on linux/osx
  -try:
  -   from gluon.winservice import web2py_windows_service_handler
  -except: pass
"web2py" should not be capitalized. The name is always lower case.
I am not sure what this does
  path = os.path.dirname(__file__)
when running the binary versions. We need to try it. What is
classtring for? Does it need to be path dependent?
Does winservice.py makes any sense without an installer? I think we
need a windows installer that installs web2py, ulipad, a hook to the
shell, Â two services (80, 443) and packages a nice windows menu to
run this all.
Forum http://groups.google.com/group/python_study
※※※※※※※※※※※※※※※※※※※※※※※※
--
※※※※※※※※※※※※※※※※※※※※※※※※
My blog: http://blog.donews.com/ygao
Forum http://groups.google.com/group/python_study
※※※※※※※※※※※※※※※※※※※※※※※※
Massimo
Massimo
Rest assured the windows version will continue to be without an
installer.
I am just suggesting that perhaps there should be a second windows
distribution that packages more stuff, including third party stuff,
which may require installation.
I am not going to maintain this but if windows users think it is
valuable and somebody is willing to work on it, I do not mind posting
it.
Massimo
python web2py.py -W install
python web2py.py -W start
And you need copy options_std.py to options.py, and change some option
values before you start the service.
> - options in an easy way
just like what I've written above, and you can still use command line
options and save it as a bat file.
python web2py.py -a password
> - no welcome app launch by default
See this thread:
http://groups.google.com/group/web2py/browse_thread/thread/7854353eb6d6bab9/f0071bf800c1fdde#f0071bf800c1fdde
> - no initial GUI (maybe differentiating a development source and a
use command line option -a password.
> deployment package)
>
Don't understand very much.
python web2py.py -h
and removing the applications/welcome folder.
Perhaps I misunderstood your suggestion.
Massimo
-a '<recycle>'
or on windows
-a "<recycle>"
will reuse the previous password
Massimo
Massimo
Massimo
If you have time, could you please check and eventually correct/
extend this:
http://mdp.cti.depaul.edu/AlterEgo/default/show/77
Massimo
I changed some words, and you can review them.
Massimo