sudo ufw enable
允許MySQL連線
sudo ufw allow mysql
允許SSH連線
sudo ufw allow ssh
或
sudo ufw allow 22
參考資料:
UFW Essentials: Common Firewall Rules and Commands
Install MySQL Server on the Ubuntu operating system
sudo ufw enable
sudo ufw allow mysql
sudo ufw allow ssh
sudo ufw allow 22
var emitter = require('events').EventEmitter;
// need util module when using inherits
var util = require('util');
function LoopProcessor(num) {
// create a new object for current class
var me = this;
setTimeout(function () {
for (var i = 1; i <= num; i++) {
me.emit('BeforeProcess', i);
console.log('Processing number:' + i);
me.emit('AfterProcess', i);
}
}
, 2000)
return this;
}
//LoopProcessor is inherited from emitter class
util.inherits(LoopProcessor, emitter)
var lp = new LoopProcessor(3);
lp.on('BeforeProcess', function (data) {
console.log('About to start the process for ' + data);
});
lp.on('AfterProcess', function (data) {
console.log('Completed processing ' + data);
});
function LoopProcessor(num) {
// create a new object for current class
var me = this;
setTimeout(function () {
for (var i = 1; i <= num; i++) {
me.emit('BeforeProcess', i);
console.log('Processing number:' + i);
me.emit('AfterProcess', i);
}
}
, 2000)
return this;
}
var emitter = require('events').EventEmitter;
// need util module when using inherits
var util = require('util');
function LoopProcessor(num) {
// create a new object for current class
// var me = this;
setTimeout(function () {
for (var i = 1; i <= num; i++) {
// me.emit('BeforeProcess', i);
console.log('Processing number:' + i);
// me.emit('AfterProcess', i);
}
}
, 2000)
// return this;
}
//LoopProcessor is inherited from emitter class
util.inherits(LoopProcessor, emitter)
var lp = new LoopProcessor(3);
lp.on('BeforeProcess', function (data) {
console.log('About to start the process for ' + data);
});
lp.on('AfterProcess', function (data) {
console.log('Completed processing ' + data);
});
// get the reference of EventEmitter class of events module
var events = require('events');
// create an object of EventEmitter class by using above reference.
var em = new events.EventEmitter();
// bind the function with a event
em.on('FirstEvent', function (data) {
console.log('First subscriber:' + data);
});
// emit event
em.emit('FirstEvent', 'I have entered the first Event!!');
// get the reference of EventEmitter class of events module
var events = require('events');
//create an object of EventEmitter class by using above reference.
var em = new events.EventEmitter();
// Create an event handler:
var myEventHandler = function (data) {
console.log('First subscriber:' + data);
}
// bind the function with a event
em.on('FirstEvent', myEventHandler);
//bind the function with a event
//em.on('FirstEvent', function (data) {
// console.log('First subscriber:' + data);
//});
//emit event
em.emit('FirstEvent', 'I have entered the first Event!!');