> Hello,
>
> You guys are always so helpful so I thought I'd come here with my
> crazy problem I'm trying to solve.
>
> I have a Django Application Cluster. We use subversion for our code.
> The only type of a post-commit hook we have is an HTTP Request with
> JSON at a URL we define. Essentially what I want to do is to use this
> post-commit hook to trigger a cluster-wise reload of the uwsgi
> service.
>
> The problem is that I don't really want to implement a fancy script
> that uses SSH or anything along those lines. First off, there are
> security issues. Secondly, I want it to be relatively quick and
> integrated into our app for easy replication as we add and remove
> nodes.
>
> I started off with some code -- just trying to play around the idea. I
> want to have two views. The first view is titled "svn_hook". This view
> is tied to the URL that is called from the post-commit hook by our SVN
> Hosting Provider. The second view is titled "uwsgi_reload".
>
> svn_hook()'s job is to simply open a connection with each of the nodes
> and call their uwsgi_reload() views. uwsgi_reload()'s job is to simply
> execute /etc/init.d/uwsgi... reload.
>
> Unfortunately, I have *no* idea how to get this thing to work. I tried
> approaching it with some RPC code in MoinMoin that I was forwarded to
> by a nice guy in #wsgi. But, as it turns out, I have no idea what I'm
> doing :)
>
> I think if I can get the servers to talk to each other, then I can
> handle the rest. If you guys have any ideas on either how to fix this
> code, or a better way of approaching this problem, I would really
> appreciate the input.
>
> By the way, I understand that WSGI is a completely different protocol
> from HTTP. I tried to understand the code the best I could and had no
> idea what was going on exactly with the key/value pairs I saw in the
> MoinMoin code. Hopefully someone can understand what I was trying to
> accomplish there
>
> Thanks again!
> -Kurtis
>
> from django.http import HttpResponse
>
> # View for URL Called by SVN on Post-Commit Hook
> def svn_hook(request):
>
>     # Resources
>     # import urllib # Used in example code, not here yet...
>     from httplib import HTTPConnection
>
>     # List of IP Addresses to Reload
>     # <Real IP's Hidden>
>     hosts = ('192.168.1.1', '192.168.1.2')
>     port = '7999'
>
>     # Hit the Server
>     """
>
>     Note:
>     I was going to do more here ... but I can't
>     even get the thing to work without stalling or throwing
>     errors. I wanted to check for a 200 Status from each
>     host and eventually log if any fail.
>
>     """
>     for host in hosts:
>         client = HTTPConnection(host, port, False, 30)
>         client.request("GET", '/reload')
>         response = client.getresponse()
>         body = response.read()
>         body = body.decode('utf-8')
>
>     # Done
>     return HttpResponse(status = 200)
>
> # Temporarily set as /reload for testing purposes.
> def uwsgi_reload(request):
>
>     # Execute /etc/init.d/uwsgi.... reload
>     # and any other logic that may need to be performed
>     # I'll do this later, after I get the actual WSGI call
>     # working.
>
>     return HttpResponse(status = 200)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


Are your servers on a multicast-enabled network ?

If they are you can use this

http://projects.unbit.it/uwsgi/wiki/Clustering

Your svn hook will be only a one-line:

os.system("uwsgi --cluster-reload <address>")

-- 
Roberto De Ioris
http://unbit.it

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to