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)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)| # https://github.com/ipaddress-gem/ipaddress | |
| require 'ipaddress' | |
| class Calculator | |
| def self.run(top, parts: nil, prefixes: nil) | |
| top = IPAddress(top) | |
| subnets = by_parts(top, parts) if parts | |
| subnets = by_prefixes(top, prefixes) if prefixes | |
| subnets | |
| end |
| defmodule GRPCSentry.ServerInterceptor do | |
| @behaviour GRPC.ServerInterceptor | |
| def init(opts), do: opts | |
| def call(req, stream, next, _opts) do | |
| result = next.(req, stream) | |
| case result do |
Client and server use test.proto and the gRPC over HTTP/2 v2 protocol.
| defmodule Diff do | |
| def diff(left, right, %{diff_type: :cli} = config) do | |
| # %{enabled: true} | |
| Diff.Cli.diff(left, right, config) | |
| end | |
| def format_sides(left, right, formatter) do | |
| case format_diff(left, right, formatter) do | |
| {left, right} -> | |
| {IO.iodata_to_binary(left), IO.iodata_to_binary(right)} |
| # 1.4 on ubuntu 14.04 | |
| wget https://mirrors.tuna.tsinghua.edu.cn/erlang-solutions/ubuntu/pool/esl-erlang_19.2-1~ubuntu~trusty_amd64.deb | |
| sudo dpkg -i esl-erlang_19.2-1~ubuntu~trusty_amd64.deb | |
| sudo apt-get -f -y install | |
| sudo dpkg -i esl-erlang_19.2-1~ubuntu~trusty_amd64.deb | |
| wget https://mirrors.tuna.tsinghua.edu.cn/erlang-solutions/ubuntu/pool/elixir_1.4.1-1~ubuntu~trusty_all.deb | |
| sudo dpkg -i elixir_1.4.1-1~ubuntu~trusty_all.deb | |
| elixir -v | |
| # 1.5 on ubuntu 14.04 |
| # git clone https://github.com/hexpm/hex.git | |
| # cd hex | |
| # git checkout v0.15.0 | |
| # # Add this Dockerfile in the dir | |
| # docker build . | |
| # # Then you can use the image as your base image to speedup your usage | |
| FROM elixir:1.5.2 | |
| RUN HEX_MIRROR=https://hexpm.upyun.com mix local.rebar --force \ | |
| # rebar3 update should be rerun if you add a new rebar dependence |
With Node you can write very fast JavaScript programs serverside. It's pretty easy to install Node, code your program, and run it. But > how do you make it run nicely in the background like a true server?
/etc/init/$ sudo vim yourapp.conf$ sudo start yourapp$ sudo stop yourapp | defmodule FSM do | |
| defmacro __using__(opts) do | |
| quote do | |
| import FSM.DSL, only: [trans: 3] | |
| Module.register_attribute(__MODULE__, :events, accumulate: true) | |
| @before_compile FSM.DSL | |
| end | |
| end | |
| end |
| sysctl -w fs.file-max=12000500 | |
| sysctl -w fs.nr_open=20000500 | |
| ulimit -n 4000000 | |
| sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000' | |
| sysctl -w net.ipv4.tcp_rmem='1024 4096 16384' | |
| sysctl -w net.ipv4.tcp_wmem='1024 4096 16384' | |
| sysctl -w net.core.rmem_max=16384 | |
| sysctl -w net.core.wmem_max=16384 | |
| wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb | |
| sudo dpkg -i erlang-solutions_1.0_all.deb |