Thanks! Here come the files
1. application.ex
defmodule LogServer.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
def start(_type, _args) do
# List all child processes to be supervised
children = [
# Start the Ecto repository
LogServer.Repo,
# Start the endpoint when the application starts
LogServerWeb.Endpoint
# Starts a worker by calling: LogServer.Worker.start_link(arg)
# {LogServer.Worker, arg},
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: LogServer.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
LogServerWeb.Endpoint.config_change(changed, removed)
:ok
end
end
2. endpoint.ex
defmodule LogServerWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :log_server
socket "/socket", LogServerWeb.UserSocket,
websocket: true,
longpoll: false
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phx.digest
# when deploying your static files in production.
plug Plug.Static,
at: "/",
from: :log_server,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
if code_reloading? do
socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
plug Phoenix.LiveReloader
plug Phoenix.CodeReloader
end
plug Corsica,
origins: ["https://knode.io", "https://206.189.184.194", "http://localhost:8175", "http://localhost:8000"],
log: [rejected: :error, invalid: :warn, accepted: :debug],
allow_headers: ["content-type", "accept", "authorization"]
##origins: ["https://206.189.184.194", "http:/localhost:8175"],
plug Plug.RequestId
plug Plug.Logger
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug Plug.MethodOverride
plug Plug.Head
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
plug Plug.Session,
store: :cookie,
key: "_log_server_key",
signing_salt: "L8GfiIiZ"
plug LogServerWeb.Router
end
3, config.exs*
use Mix.Config
config :log_server,
ecto_repos: [LogServer.Repo]
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:request_id]
config :phoenix, :json_library, Jason
import_config "#{Mix.env()}.exs"