作为服务运行时没有这样的文件或目录?

时间:2017-06-28 18:52:49

标签: go

当我从终端sudo -u www-data ./scarga运行我的应用程序并打开浏览器时,模板文件服务良好,一切正常。命令从/var/www/html/scarga.local/目录执行。

当我将应用程序作为sudo service scarga start运行时,它会显示:open ./resources/views/index.html: no such file or directory

使用HTTP处理程序的文件:https://pastebin.com/MU7YDAWV

scarga.service文件:https://pastebin.com/eBL3jJFx

项目树:https://pastebin.com/rFVa8A3P

index.html file 的权利 - rwxr-xr-x 1 www-data www-data 3586 Jun 28 14:27 index.html`

为什么会发生这种情况以及如何解决?

谢谢!

1 个答案:

答案 0 :(得分:2)

您需要使用#models.py class Student(models.Model): # STEP 1 BASIC INFO student_id = models.CharField(max_length=128, unique=True) first_name = models.CharField(max_length=128) last_name = models.CharField(max_length=128) ssn = USSocialSecurityNumberField(null=False) gender = models.CharField(max_length=128, choices=GENDER_CHOICES) dob = models.DateField(auto_now=False, auto_now_add=False, db_column="date of birth") contact_number = models.CharField(max_length=128) address = models.CharField(max_length=128) city = models.CharField(max_length=128) state = USStateField(choices=STATE_CHOICES, default='NJ') zipcode = USZipCodeField(blank=True) country = CountryField(default='US', blank=True) home_phone = models.CharField(max_length=128) cell_phone = models.CharField(max_length=128) email = models.EmailField(max_length=254, validators=[validate_email]) def __str__(self): return self.first_name + self.last_name #views.py def search_Student(request): context_dict = {} if request.method == 'POST': query = request.POST['last_name_search'] results = Student.objects.filter(last_name=query) if query: context_dict['results'] = results else: context_dict['no_results'] = query return render(request, "students/search_student.html", context_dict) #search_student.html {% block main_content %} <form method="post" action="/students/search_student/"> {% csrf_token %} <label for="last_name_search">Last Name:</label> <input type="text" name="last_name_search" id="last_name_search"> <input type="submit" name="submit"> </form> <div id="result_panel"> {% if no_results %} No results returned for <q>{{ no_results }}</q> {% else %} {% for result in results %} {{ result.last_name }} {% endfor %} {% endif %} </div> {% endblock %} #urls.py urlpatterns = [ url(r'^$', students_views.Students, name='students'), url(r'^add_student/$', students_views.add_Student, name='add_student'), url(r'^id=(?P<identify>[\w]+)/add_studentcourse/$', students_views.add_StudentCourse, name='add_studentcourse'), url(r'^id=(?P<identify>[\w]+)/add_studentemployment/$', students_views.add_StudentEmployment, name='add_studentemployment'), url(r'test/$', students_views.test, name='test'), #URL for the search page. url(r'^search_student/$', students_views.search_Student, name='search_student'), url(r'^current_student/$', students_views.current_Student, name='current_student'), url(r'^all_my_student/$', students_views.all_My_Student, name='all_my_student'), url(r'^public_student/$', students_views.public_Student, name='public_student'), url(r'^sales_reports/$', students_views.sales_Reports, name='sales_reports'), url(r'^switch_counselor/$', students_views.switch_Counselor, name='switch_counselor'), url(r'^source_admin/$', students_views.source_Admin, name='source_admin'), url(r'^super_tool/$', students_views.super_Tool, name='super_tool'), url(r'^help_and_settings/$', students_views.help_And_Settings, name='help_and_settings'), ] 在脚本中设置正确的工作目录 - 大概是:

WorkingDirectory=