因此,我一直在尝试为我的应用程序设置代码部署,但始终失败。最初,我在存储库中没有appspec.yml文件,因此我收到错误消息,指出appspec.yml文件不存在。
我现在包含了一个appspec.yml文件,但是它仍然无法正常工作,并且没有给出任何错误消息。没有提到任何事件,就像添加appspec文件之前的事件一样。
关于创建appspec.yml文件,我的知识还不多,但是我从youtube教程中得到了提示,这里是文件。
version: 0.0
os: linux
files:
- source: /
destination: /var/www/cms
Run Code Online (Sandbox Code Playgroud)
如果有帮助,则ec2实例正在运行ubuntu服务器,/ ng / www / cms是该目录,nginx应该在该目录中提供文件。
这是我的项目文件夹
/
public/
index.html
main.js
adaptor.js
main.css
node_modules/
socket.io/
index.js
Run Code Online (Sandbox Code Playgroud)
这是我的index.js中的静态文件配置
app.use(express.static(path.join(__dirname, '/public')));
app.use(express.static(path.join(__dirname, '/node_modules')));
app.get('/', (req, res)=>{
res.sendFile(path.join(__dirname, 'public', '/index.html'));
})
Run Code Online (Sandbox Code Playgroud)
这是我的index.html
<script src="/socket.io/socket.io.js" charset="utf-8"></script>
<script src="/adapter.js" charset="utf-8"></script>
<script src="/main.js" charset="utf-8"></script>
Run Code Online (Sandbox Code Playgroud)
这是我的nginx配置
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html =404;
proxy_pass http://localhost:8080;
}
Run Code Online (Sandbox Code Playgroud)
但是我在所有脚本上都获得了404.另一个奇怪的事情是那些文件上的mime-type被设置为text/HTML
我在这做错了什么?
我有一个项目,具有相同的项目结构,并且具有相同的配置,但它适用于它,并且在这种情况下它不起作用.
What I am trying to achieve?
To setup socket.io on my ec2 instances, with Nginx as the web server, with an AWS Application Load Balancer, and Route53 that resolves the DNS to point to my Application Load Balancer.
Here are the list of solutions that I found online that I have tried:
Use Network load balancer instead with TCP 80, and TCP 443, and SSL at the application level. The client socket connect url would be https://mydomain:9000 and I keep …
我是 Spring 生态系统的新手。我被这种特殊情况困住了。我的应用程序服务器响应404我所有的 API 端点。
这是我的控制器
package com.example.controllers;
import com.example.models.Movie;
import com.example.services.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@RestController
public class MovieController {
@Autowired
private MovieService movieService;
@RequestMapping(value = "/movies", method = RequestMethod.GET)
@ResponseBody
public List<Movie> getAllMovies(){
return movieService.getAllMovies();
}
@RequestMapping(value = "/movies", method = RequestMethod.POST)
@ResponseBody
public Movie addNewMovie(@RequestBody Movie movie){
System.out.println("Hello World");
return movieService.addMovie(movie);
}
@RequestMapping(value = "/movies/{id}", method = RequestMethod.GET)
@ResponseBody
public Optional<Movie> getMovieById(@PathVariable String id){
return movieService.getMovieById(id);
}
@RequestMapping(value = "/movies", method …Run Code Online (Sandbox Code Playgroud) 这是 app.js 文件
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import http from 'http';
import event from 'events';
import io from 'socket.io';
import session from 'express-session';
import passport from 'passport';
import LocalStrategy from 'passport-local';
import multer from 'multer';
import fs from 'fs';
import passportLocalMongoose from 'passport-local-mongoose';
import postRoutes from './server/routes/posts.routes';
import commentRoutes from './server/routes/comments.routes';
import authRoutes from './server/routes/auth.routes';
import userRoutes from './server/routes/users.routes';
import {passportConfig} from './server/config/passport.config';
import {socketFunction} from './server/config/socket.io.config';
import path from 'path';
mongoose.connect('mongodb://localhost/blog'); …Run Code Online (Sandbox Code Playgroud) 这是我的模型,
var InternetSchema = new Schema({
name: String,
company: String,
contactNumber:String,
accessToken:String,
});
InternetSchema.index({name: 'text', company: 'text');
export default mongoose.model('Internet', InternetSchema);
Run Code Online (Sandbox Code Playgroud)
这是我响应搜索 API 的函数
export function getSearchAccess(req, res) {
// const arr = [
// {name: req.params.term},
// {company: req.params.term}
// ]
console.log(req.params.term)
Internet.find({
$text: {
$search: req.params.term
}
}).limit(10).exec(function(finderr, finddata) {
return res.json({ count: 10, data: finddata });
});
}
Run Code Online (Sandbox Code Playgroud)
但是,这似乎只能获取与该name字段匹配的文档。它不匹配company。
我尝试在 mongo shell 中测试它,它不会获取公司的任何数据,但会获取名称的数据
export function postComment(req, res) {
const user = decodeToken(req);
let saveComment, saveJob, saveUser, activity, jobUser;
function pushToJob(comment) {
saveComment = comment;
Job.findById(req.params.id)
.then((data) => {
job = data;
data.comments.push(saveComment._id)
return data.save()
}).catch((err) => {
throw new Error(`The error at pushing to job is ${err}`)
})
}
function updateCommentWithJobId(job) {
saveComment.jobId = {
_id: job._id,
title: job.title
}
return saveComment.save()
}
function addActivityToUser(comment) {
saveComment = comment;
User.findById(user._id)
.then((data) => {
saveUser = data;
activity = {
activity: 'comment',
comment: saveComment._id, …Run Code Online (Sandbox Code Playgroud) node.js ×5
nginx ×2
eventemitter ×1
express ×1
javascript ×1
mongodb ×1
mongoose ×1
socket.io ×1
sockets ×1
spring ×1
spring-boot ×1