Skip to content

Instantly share code, notes, and snippets.

@cybergrind
Forked from valinurovam/gist:3358483
Created August 15, 2012 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cybergrind/3359248 to your computer and use it in GitHub Desktop.
Save cybergrind/3359248 to your computer and use it in GitHub Desktop.
process_file(StatusFileName, Table) ->
FileName = ?STATUS_FILES_DIR ++ StatusFileName,
{ok, IoD} = file:open(FileName, read),
HttpURL = io:get_line(IoD, ''),
file:close(IoD),
{ok, {{_Version, 200, ReasonPhrase}, _Headers, _Body}} = httpc:request(HttpURL),
file:delete(FileName),
ets:insert(Table, {StatusFileName, -1}).
do_process() ->
try
process_file(status, table)
catch
Err:Rsn ->
log(....),
ets:insert(table, {status, 0})
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment