Merge branch 'feat-live-view' into 'master'
feat: Setup clustered dev mode See merge request mythic-insight/legendary!67
This commit is contained in:
		
						commit
						966ca66345
					
				
					 7 changed files with 2617 additions and 4385 deletions
				
			
		
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -34,8 +34,8 @@ node_modules
 | 
				
			||||||
/priv/static/
 | 
					/priv/static/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Mnesia DBs
 | 
					# Mnesia DBs
 | 
				
			||||||
/apps/*/priv/mnesia/
 | 
					/apps/*/priv/mnesia*
 | 
				
			||||||
/priv/mnesia/
 | 
					/priv/mnesia*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Lock file for Brew, since the versions aren't really stable & isolated anyway
 | 
					# Lock file for Brew, since the versions aren't really stable & isolated anyway
 | 
				
			||||||
Brewfile.lock.json
 | 
					Brewfile.lock.json
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,7 +74,7 @@ config :app,
 | 
				
			||||||
  crontab: [
 | 
					  crontab: [
 | 
				
			||||||
  ]
 | 
					  ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
config :mnesia, dir: to_charlist(Path.expand("./priv/mnesia"))
 | 
					config :mnesia, dir: to_charlist(Path.expand("./priv/mnesia@#{Kernel.node}"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Feature flags
 | 
					# Feature flags
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,7 @@ use Mix.Config
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
|> Enum.map(fn {otp_app, module} ->
 | 
					|> Enum.map(fn {otp_app, module} ->
 | 
				
			||||||
  config otp_app, Module.concat(module, "Endpoint"),
 | 
					  config otp_app, Module.concat(module, "Endpoint"),
 | 
				
			||||||
    http: [port: 4000],
 | 
					    http: [port: String.to_integer(System.get_env("PORT") || "4000")],
 | 
				
			||||||
    debug_errors: true,
 | 
					    debug_errors: true,
 | 
				
			||||||
    code_reloader: true,
 | 
					    code_reloader: true,
 | 
				
			||||||
    check_origin: false,
 | 
					    check_origin: false,
 | 
				
			||||||
| 
						 | 
					@ -29,13 +29,13 @@ use Mix.Config
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  config otp_app, Module.concat(module, "Endpoint"),
 | 
					  config otp_app, AppWeb.Endpoint,
 | 
				
			||||||
    live_reload: [
 | 
					    live_reload: [
 | 
				
			||||||
      patterns: [
 | 
					      patterns: [
 | 
				
			||||||
        ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
 | 
					        ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
 | 
				
			||||||
        ~r"priv/gettext/.*(po)$",
 | 
					        ~r"priv/gettext/.*(po)$",
 | 
				
			||||||
        ~r"lib/app/(live|views)/.*(ex)$",
 | 
					        ~r"(live|views)/.*(ex)$",
 | 
				
			||||||
        ~r"lib/app/templates/.*(eex)$"
 | 
					        ~r"templates/.*(eex)$"
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
| 
						 | 
					@ -61,7 +61,7 @@ config :core, Legendary.CoreMailer, adapter: Bamboo.LocalAdapter
 | 
				
			||||||
config :libcluster,
 | 
					config :libcluster,
 | 
				
			||||||
  topologies: [
 | 
					  topologies: [
 | 
				
			||||||
    erlang_hosts: [
 | 
					    erlang_hosts: [
 | 
				
			||||||
      strategy: Elixir.Cluster.Strategy.ErlangHosts,
 | 
					      strategy: Elixir.Cluster.Strategy.Gossip,
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
  ]
 | 
					  ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										6920
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6920
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
					@ -22,9 +22,10 @@
 | 
				
			||||||
    "@semantic-release/commit-analyzer": "^6.1.0",
 | 
					    "@semantic-release/commit-analyzer": "^6.1.0",
 | 
				
			||||||
    "@semantic-release/exec": "^5.0.0",
 | 
					    "@semantic-release/exec": "^5.0.0",
 | 
				
			||||||
    "@semantic-release/git": "^7.0.8",
 | 
					    "@semantic-release/git": "^7.0.8",
 | 
				
			||||||
    "@semantic-release/npm": "^7.0.9",
 | 
					    "@semantic-release/npm": "^7.1.3",
 | 
				
			||||||
    "dot": "^1.1.3",
 | 
					    "dot": "^1.1.3",
 | 
				
			||||||
    "semantic-release": "^15.14.0"
 | 
					    "http-proxy": "^1.18.1",
 | 
				
			||||||
 | 
					    "semantic-release": "^17.4.4"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "release": {
 | 
					  "release": {
 | 
				
			||||||
    "plugins": [
 | 
					    "plugins": [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										34
									
								
								script/proxy
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										34
									
								
								script/proxy
									
									
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var http = require('http'),
 | 
				
			||||||
 | 
					    httpProxy = require('http-proxy');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Create a proxy server with custom application logic
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					var proxy = new httpProxy.createProxyServer({});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var proxyServer = http.createServer(function (req, res) {
 | 
				
			||||||
 | 
					  proxy.web(req, res, {
 | 
				
			||||||
 | 
					    target: {
 | 
				
			||||||
 | 
					      host: 'localhost',
 | 
				
			||||||
 | 
					      port: 4001
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Listen to the `upgrade` event and proxy the
 | 
				
			||||||
 | 
					// WebSocket requests as well.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					proxyServer.on('upgrade', function (req, socket, head) {
 | 
				
			||||||
 | 
					  proxy.ws(req, socket, head, {
 | 
				
			||||||
 | 
					    target: {
 | 
				
			||||||
 | 
					      host: 'localhost',
 | 
				
			||||||
 | 
					      port: 4001
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					console.log("listening on port 4000")
 | 
				
			||||||
 | 
					proxyServer.listen(4000);
 | 
				
			||||||
							
								
								
									
										33
									
								
								script/server-clustered
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								script/server-clustered
									
									
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set -x
 | 
				
			||||||
 | 
					set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DIR_PATH=$(dirname $0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$DIR_PATH/update
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					trap_with_arg() { # from https://stackoverflow.com/a/2183063/804678
 | 
				
			||||||
 | 
					  local func="$1"; shift
 | 
				
			||||||
 | 
					  for sig in "$@"; do
 | 
				
			||||||
 | 
					    trap "$func $sig" "$sig"
 | 
				
			||||||
 | 
					  done
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					stop() {
 | 
				
			||||||
 | 
					  trap - SIGINT EXIT
 | 
				
			||||||
 | 
					  printf '\n%s\n' "received $1, killing child processes"
 | 
				
			||||||
 | 
					  kill -s SIGINT 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					trap_with_arg 'stop' EXIT SIGINT SIGTERM SIGHUP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CLUSTER_COOKIE=`openssl rand -hex 8`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PORT=4002 elixir --sname two   --cookie $CLUSTER_COOKIE -S mix phx.server 2>/dev/null &
 | 
				
			||||||
 | 
					PORT=4003 elixir --sname three --cookie $CLUSTER_COOKIE -S mix phx.server 2>/dev/null &
 | 
				
			||||||
 | 
					PORT=4004 elixir --sname four  --cookie $CLUSTER_COOKIE -S mix phx.server 2>/dev/null &
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$DIR_PATH/proxy &
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PORT=4001 iex    --sname one --cookie $CLUSTER_COOKIE -S mix phx.server
 | 
				
			||||||
		Loading…
	
		Reference in a new issue