Never use this within chef cookbooks. Check something like this: http://docs.opscode.com/resource_service.html
Writing this kind of code maybe gets executed at a wrong time. Chef runs are seperated in compile time and execution time. Your code gets executed on compile time while the resources are normally getting executed while execution time.