Skip to content

Instantly share code, notes, and snippets.

View FooBarWidget's full-sized avatar

Hongli Lai FooBarWidget

View GitHub Profile
# yum install gperftools-libs
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.nl.leaseweb.net
* epel: ftp.fau.de
* extras: mirror.proserve.nl
* updates: mirror.proserve.nl
Resolving Dependencies
--> Running transaction check
---> Package gperftools-libs.x86_64 0:2.4-5.el7 will be installed
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
i = 0
while true
begin
i += 1
puts "#{Time.now}: Pinging #{i}"
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('hello world');
});
server.listen(3000);
if (typeof PhusionPassenger !== 'undefined') {
# De toplevel module is UnionStationHooks. Maar het heeft ook een alias.
version = UnionStationHooks::VERSION_STRING
version = USH::VERSION_STRING # hetzelfde
# Initialization. Passenger roept dit aan aan het begin van een request.
reporter = UnionStationHooks.begin_request(rack_env)
# Een Reporter object is een high-level object om *request-specifieke*
# informatie te versturen naar Union Station. De applicatie kan het
# object als volgt verkrijgen:
switch {
// The following line triggers this compiler error:
// input.ch <- websocketReadResult literal used as value
case input.ch <- websocketReadResult{ messageType, p, nil }:
// Do nothing
case <- input.cancel:
conn.abortWriterFromReaderProcess()
break
}
@FooBarWidget
FooBarWidget / testprocess.py
Created January 21, 2015 13:09
Zombie process test
#!/usr/bin/env python3 -u
# This shell script simulates a CGI web server.
# Save as 'testprocess.py' and run with:
# docker run -i --rm ubuntu:14.04 python3 -u < testprocess.py
import os, signal, time
# The web server spawns a CGI script, which in turn spawns a long-running 'grep',
# simulated here by 'sleep 999'.
print("Spawning CGI script")
pid = os.fork()
This is the plan:
1. Launch server #1
2. Launch server #2
3. Launch server #3
4. Create master database instance #1 on server #1
5. Create slave database instance #2 on server #2
6. Create slave database instance #3 on server #3
Continue with this plan?
This is the plan:
1. Promote slave instance #2 (on server 192.168.0.2) to master
2. Forward port 7000 in the entire cluster to slave instance #2 (on server 192.168.0.2)
Continue with this plan? [Y/n]
$ pappardelle failover --member admin@192.168.0.3 [--new-master 192.168.0.2]
$ pappardelle set-slaves --config config.yml --count 1
This is the plan:
1. Destroy slave instance #3 (on server 192.1868.0.3)
Continue with this plan? [Y/n]