Clock server is not running

Hi,

The version of my plone is 5.2.2. I set the clock server as following:
#########################################

clock server

[instance-background-jobs]
<=instance
event-log-level = INFO
port-base = 9
z2-log-level = INFO
zodb-cache-size = 5000
zope-conf-additional =

method /Plone/@@process_background_jobs
period 7200
user zopeuser
password zopeuser
host localhost:8089

<clock-server>
   method /Plone/@@hello_world
   period 30
   user zopeuser
   password zopeuser
   host localhost:8089
</clock-server>

However, it seems to me that the clock server is not running. When I start instance by:

bin/instance fg

Or:
bin/plonectl fg

I could not see the message like :
2020-11-03 19:57:38 INFO ZServer Clock server for "...

What is the correct way to set clock server?
Is it still available for plone 5.2.2?

Thanks,

peijun

Repost the setting, do not why some lines are gone.

#########################################

clock server

[instance-background-jobs]
<=instance
event-log-level = INFO
port-base = 9
z2-log-level = INFO
zodb-cache-size = 5000
zope-conf-additional =

<clock-server>
   method /Plone/@@process_background_jobs
   period 7200
   user zopeuser
   password zopeuser
   host localhost:8089
</clock-server>

<clock-server>
   method /Plone/@@hello_world
   period 30
   user zopeuser
   password zopeuser
   host localhost:8089
</clock-server>

By default, Plone no longer runs under ZServer (it is not yet Python 3 ready). Are you sure, you have a ZServer setup?

Thanks.
No, I dont think I have set up aZServer if I have to install it manually. I just set my buildout.cfg. I think that is why it is not running. Then, how can run background jobs? Using system crontab? Or there are some Plone packages to handle this?

peijun

I see various options:

  • as long as you use Python 2, you can set up Plone to use ZServer (instead of WSGI). There is a buildout configuration variable for this -- read the documentation for plone.recipe.zope2instance to find out its name.
  • you can use the "zeoserver" setup for Plone (there the ZODB data files are not directly controlled by Plone but by a dedicated server (the so called "ZEO server") which coordinates access to them for different Zope processes) and perform background jobs in a dedicated Zope process (likely in a script)
  • you can use an external scheduling control (i.e. an external cron server) and call appropriate views in Zope via HTTP automation. Operating systems typically come with such a scheduling service ("cron" for *nix like systems).
  • in principle, the available configuration options differ for Zope with ZServer and Zope with WSGI. That you are able to use the clockserver option may indicate, that you are either using ZServer or that clockserver should work also in a WSGI setup. In the latter case, you would see a Zope bug which you could report in the Zope bug tracker (--> "https://github.com/zopefoundation/Zope`).
2 Likes

Thanks a lot.

I have solved this issue by using daemonized thread in my views.py, like:



    def daemon_thread(self, job_id, request):    
        thread = threading.Thread(target=self.daemon_process, kwargs={'job_id':job_id,'request': request})
        thread.daemon = True                            
        thread.start() 
    
    def daemon_process(self,job_id, request):
        # code for your process

If you daemonize inside the python process, that process is started/managed by the wsgi server. Depending on its implementation and running multiple processes, isn’t there the risk of the subprocess getting killed or started multiple times?

ftw.upgrade has an inbuilt feature to call views in a running zope instance by arranging the authorisation through a shared key on file system, for example to call combine_bundles. It would be cool to have this in a separate package.

The drawback of using wget/curl in a cronjob is that you have to provide user/password to the url fetching app