mirror of
https://github.com/Dannecron/hello-slack-bot.git
synced 2025-12-25 16:12:34 +03:00
add https settings and service
This commit is contained in:
13
app.js
13
app.js
@@ -1,9 +1,18 @@
|
|||||||
var express = require('express');
|
var express = require('express');
|
||||||
var bodyParser = require('body-parser');
|
var bodyParser = require('body-parser');
|
||||||
|
var https = require('https');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
var zmrBot = require('./bot.js');
|
var zmrBot = require('./bot.js');
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
var port = process.env.PORT || 3000;
|
var port = process.env.PORT || 3000;
|
||||||
|
var sslPath = '/etc/letsencrypt/live/sao.twilightparadox.com/';
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
key: fs.readFileSync(sslPath + 'privkey.pem'),
|
||||||
|
cert: fs.readFileSync(sslPath + 'fullchain.pem')
|
||||||
|
};
|
||||||
|
|
||||||
// body parser middleware
|
// body parser middleware
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
@@ -19,6 +28,10 @@ app.use(function (err, req, res, next) {
|
|||||||
res.status(400).send(err.message);
|
res.status(400).send(err.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var server = http.createServer(options, app);
|
||||||
|
var io = require('socket.io').listen(server);
|
||||||
|
server.listen(443);
|
||||||
|
|
||||||
app.listen(port, function () {
|
app.listen(port, function () {
|
||||||
console.log('Slack bot listening on port ' + port);
|
console.log('Slack bot listening on port ' + port);
|
||||||
});
|
});
|
||||||
13
slackbot.service
Normal file
13
slackbot.service
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Your app
|
||||||
|
After=network.target
|
||||||
|
[Service]
|
||||||
|
ExecStart=/var/www/myapp/app.js
|
||||||
|
Restart=always
|
||||||
|
User=nobody
|
||||||
|
Group=nobody
|
||||||
|
Environment=PATH=/usr/bin:/usr/local/bin
|
||||||
|
Environment=NODE_ENV=production
|
||||||
|
WorkingDirectory=/var/www/myapp
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user