2015-10-26 122 views
0

运行Django的服务器流浪汉后,django server应自动运行,但我无法得到它的工作,无法在厨师

流浪汉SSH之后,manage.py/pro/e7, 在厨师食谱,我做

execute 'django_server' do 
    command 'python ./manage.py runserver' 
end 

当我发出命令

vagrant provision 

它说

python can't find the file. 

我不知道如何解决它..请帮助,如果你知道它

回答

0

的Python不知道manage.py路径。要么使用的manage.py完整路径,如果路径是/pro/e7/manage.py然后使用类似:

execute "django_server" do 
    cwd "/pro/e7" 
    command "python ./manage.py runserver" 
end 

,如果你不知道的manage.py路径或您想将其暴露在特定的位置,那么你可以这样做:

cookbook_file "/home/username/manage.py" do 
    source "/full-path-of/manage.py(in hosts system)" 
    owner "username" 
    group "username" 
    mode "0755" 
    action :create 
end 
execute "django_server" do 
    cwd "/home/username/" 
    command "python ./manage.py runserver" 
end 

它会将manage.py文件放在/home/username/的流浪客机中并执行。

+0

['execute'](https://docs.chef.io/resource_execute.html)资源有一个'cwd'属性,其目的不是使用'cd/path &&' – Tensibai