AS
Size: a a a
AS
Д
Д
Д
A
const JwtStrategy = require("passport-jwt").Strategy;
ExtractJwt = require('passport-jwt').ExtractJwt;
const User=require("../../mongodb/models/User");
module.exports = function(passport){
let opts = {};
opts.jwtFromRequest= ExtractJwt.fromHeader('test'.toLowerCase())
opts.secretOrKey = 'weeee';
passport.use(new JwtStrategy(opts,function(jwt_payload,done){
console.log('WWWW')
User.getUserById(jwt_payload._id, function(err,user){
if(err){
return done(err, false);
}
if(user){
return done(null, user);
}
else{
return done(null, false);
}
});
}));
} require('./routes/jwt')(passport);
app.use(passport.initialize());
app.use(passport.session())
app.post('/protected', passport.authenticate('jwt', { session: false }), (req, res) => {
console.log(req.get('Authorization'));
res.send('Hello')A
AS
Д
Д
ZM
sudo -E pm2 start index.js --name=имяД
sudo -E pm2 start index.js --name=имяA
ZM
Д
ZM
VK
const commands = ['python3 p.py', 'python3 z.py', ...].json('s') <- вот это не должно ждать exec-ов
exec(commands[0]), дождаться выполнения, затем exec(commands[1]) и т.д.
res
CI
CI
queue = []Можно как-нибудь улучшить? При запросе с командой. из контроллера вызывается scheduler(command)
async function scheduler(command) {
if (queue.length === 0) {
queue.push(command)
while (queue.length !== 0) {
const { stdout, stderr } = await exec(queue[0])
queue.shift()
console.log('command is done ' + `left: ${queue.length}`)
}
} else {
queue.push(command)
}
}
Д
Д
queue = []Можно как-нибудь улучшить? При запросе с командой. из контроллера вызывается scheduler(command)
async function scheduler(command) {
if (queue.length === 0) {
queue.push(command)
while (queue.length !== 0) {
const { stdout, stderr } = await exec(queue[0])
queue.shift()
console.log('command is done ' + `left: ${queue.length}`)
}
} else {
queue.push(command)
}
}