How can a nodejs process running inside a docker container, get that container's id?
the hostname seems to be the short container id in Docker v1.12
It works and this idea was found in this SO post.
var _ = require('underscore'); | |
var omitEmptyValues = function omitEmptyValues(data) { | |
if(!_.isObject(data)) { | |
return data; | |
} | |
else { | |
if (_.isArray(data)) { | |
var clone = []; | |
_.each(data, function(value) { |
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: dropbox | |
# Required-Start: $local_fs $remote_fs $network $syslog $named | |
# Required-Stop: $local_fs $remote_fs $network $syslog $named | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# X-Interactive: false | |
# Short-Description: dropbox service | |
### END INIT INFO |
const os = require('os'); | |
var kue = require('kue'); | |
var queue = kue.createQueue({ | |
redis: process.env.REDIS_URL | |
}); | |
var JOB_NAME = 'crawl'; |
How can a nodejs process running inside a docker container, get that container's id?
the hostname seems to be the short container id in Docker v1.12
It works and this idea was found in this SO post.
var kue = require('kue') | |
var queue = kue.createQueue({ | |
redis: process.env.REDIS_URL | |
}); | |
var JOB_NAME = 'crawl'; | |
queue.process(JOB_NAME, function(job, ctx, done){ | |
console.log((new Date()).toLocaleString(), 'inside queue.process("'+JOB_NAME+'") for job id:', job.id); |
var kue = require('kue') | |
var queue = kue.createQueue({ | |
redis: process.env.REDIS_URL | |
}); | |
queue.process('crawl', function(job, ctx, done){ | |
console.log((new Date()).toLocaleString(), 'inside queue.process("crawl") for job id:', job.id); | |
doSomething(job.data, ctx, done); | |
//exit(); // Scenario C: don't like it because shutdown can happen before the job finishes, |
Plugin docs are available here: https://marketplace.visualstudio.com/items?itemName=lukasz-wronski.ftp-sync
Plugin repo is available here: https://github.com/lukasz-wronski/vscode-ftp-sync
Configuration is saved in .vscode/ftp-sync.json
Similar instructions available at: https://training.shoppinpal.com/configuring-webstorm/sftp-with-visual-studio.html
var AWS = require('aws-sdk'); | |
var s3 = new AWS.S3(); | |
s3.getObject({ | |
Bucket: 'bucket-name', | |
Key: 'file-name.ext' | |
}, function (err, data) { | |
if (err) { | |
logger.error(err); | |
returnResponse(res, 500, logger, 'Internal Server Error') ; | |
} |
bower install angular-socket-io`
index.html
to provide a websocket implementation like socket.io
and the wrapper utility:<script src="//cdn.socket.io/socket.io-1.1.0.js"></script>
<script src="bower_components/angular-socket-io/socket.min.js"></script>
// starting point was: https://github.com/mminer/blog-code/blob/master/pattern-for-async-task-queue-results/notifier.js | |
var express = require('express'), | |
app = express(), | |
server = require('http').Server(app), | |
io = require('socket.io')(server), | |
bodyParser = require('body-parser'); | |
// After scaling up, multiple servers can only work with sockets connected to them. | |
// The socket.io-redis package can solve this by making redis the datastore instead of memory. |