Look at LSB init scripts for more information.
Copy to /etc/init.d
:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
const WebSocket = require('ws'); | |
const short = require('short-uuid'); | |
const connections = {}; | |
const send = (connectionId, data) => { | |
const connection = connections[connectionId]; | |
connection.send(data); | |
} | |
const defaultActions = { |
const WebSocket = require('ws'); | |
const wss = new WebSocket.Server({port: 8080}); | |
wss.on('connection', socket => { | |
socket.on('message', data => { | |
socket.send(data); | |
}); | |
}); | |
console.log(`Listening on ws://localhost:8080`); |
const WebSocket = require('ws'); | |
const readline = require('readline'); | |
const url = process.argv[2]; | |
const ws = new WebSocket(url); | |
ws.on('open', () => console.log('connected')); | |
ws.on('message', data => console.log(`From server: ${data}`)); | |
ws.on('close', () => { | |
console.log('disconnected'); |
const { | |
GraphQLSchema, | |
GraphQLObjectType, | |
GraphQLString, | |
GraphQLList, | |
} = require('graphql'); | |
const helloType = new GraphQLObjectType({ | |
name: 'helloType', | |
fields: () => ({ |
function createSourceEventStream( | |
schema: GraphQLSchema, | |
document: DocumentNode, | |
rootValue?: mixed, | |
contextValue?: mixed, | |
variableValues?: ?{[key: string]: mixed}, | |
operationName?: ?string, | |
fieldResolver?: ?GraphQLFieldResolver<any, any> | |
): Promise<AsyncIterable<mixed>> { | |
return new Promise((resolve, reject) => { |
import sleep from 'sleep-promise'; | |
class DispatchQueue { | |
constructor(rateLimitInSeconds) { | |
this.rateLimit = rateLimitInSeconds * 1000; | |
this.queueSize = 0; | |
} | |
async dispatch(call) { | |
this.queueSize++; |
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.network "private_network", ip: "192.168.10.101" | |
config.vm.provider "virtualbox" do |vb| | |
vb.memory = 2048 | |
vb.cpus = 2 | |
end | |
config.vm.provision "shell", inline: <<-SHELL |
#!/bin/bash | |
SERVICE_FILE=$(tempfile) | |
echo "--- Download template ---" | |
wget -q -O "$SERVICE_FILE" 'https://gist.githubusercontent.com/robzhu/2772bc0d8cb05e45d639/raw/c6cbfe996431d9e4f9224bdec0208eb19b0e45c1/service.sh' | |
chmod +x "$SERVICE_FILE" | |
echo "" | |
echo "--- Customize ---" |
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: <NAME> | |
# Required-Start: $local_fs $network $named $time $syslog | |
# Required-Stop: $local_fs $network $named $time $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Description: <DESCRIPTION> | |
### END INIT INFO |
Look at LSB init scripts for more information.
Copy to /etc/init.d
:
# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)