Skeleton for the storage bootstrap.
We want to automate this, for example, when deploying in a docker container. A bunch of static files will be loaded into the storage, in order to be served to the clients.main
parent
65d6e5fa05
commit
3280596836
|
@ -25,7 +25,17 @@ start(_Type, StartArgs) ->
|
|||
end,
|
||||
|
||||
{ok, Port} = application:get_env(port),
|
||||
{ok, Bucket} = application:get_env(bucket),
|
||||
|
||||
Bucket = case application:get_env(bucket) of
|
||||
{ok, V} -> V;
|
||||
false -> dudeswave
|
||||
end,
|
||||
|
||||
ok = case storage:create(Bucket) of
|
||||
ok -> bootstrap(Bucket);
|
||||
{error, {already_exists, Bucket, _}} -> ok;
|
||||
_ -> exit(storage_bootstrap_failed)
|
||||
end,
|
||||
|
||||
Dispatch = cowboy_router:compile([
|
||||
{'_', [{"/", dudeswave_handler, #{bucket => Bucket}}]}
|
||||
|
@ -42,3 +52,8 @@ start(_Type, StartArgs) ->
|
|||
|
||||
stop(_State) ->
|
||||
cowboy:stop_listener(dudeswave_listener).
|
||||
|
||||
%
|
||||
% Bootstrap procedure to be completed
|
||||
%
|
||||
bootstrap(_Bucket) -> ok.
|
||||
|
|
Loading…
Reference in New Issue