[CloudI] [examples] Error adding a compiled Erlang BEAM file path with an internal service implementation

Back to archive index
Michael Truog mjtru****@proto*****
Thu Dec 23 07:06:36 JST 2021


Hi Filipe,

It is best to stick with:
{module, myservice}

That does require you have the code path added first. The ".erl", ".beam" and ".app" values will automatically add a code path if you provide the absolute path. However, you don't control the compiler options with ".erl", so you can think of these string values as a quick way to get the service running without being concerned about the details.

The ability to run a release with ".script" and ".boot" would help if you needed to add a release to CloudI that you were unable to modify. However, you would normally not use that. Instead, it is better to have each internal service have a configuration entry so their initialization occurs in a single continuous time period.

Best Regards,
Michael

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, December 22nd, 2021 at 12:57 PM, Filipe Moraes <dev_filip****@hotma*****> wrote:

> Hi Michael,
>
> thanks for the fix. By the way, which one is the preferable way to add a beam service?
>
> #1 Adding "/path/to/ebin" to .conf
> cat << EOF > priv/cloudi/myservice.conf
> [[{prefix, "/sandbox/"},
> {type, internal},
> {module, "/path/to/ebin/myservice.beam"}]]
> EOF
> curl -XPOST -d @priv/cloudi/myservice.conf http://localhost:6464/cloudi/api/rpc/services_add.erl
>
> or
>
> #2 Adding "/path/to/ebin" to code_path
> cat << EOF > priv/cloudi/myservice.conf
> [[{prefix, "/sandbox/"},
> {type, internal},
> {module, myservice}]]
> EOF
> curl -XPOST -d '"'/path/to/ebin'"' http://localhost:6464/cloudi/api/rpc/code_path_add.erl
> curl -X POST -d @priv/cloudi/myservice.conf http://localhost:6464/cloudi/api/rpc/services_add.erl
>
> Best,
> Filipe Moraes
>
> ---------------------------------------------------------------
>
> De: Michael Truog <mjtru****@proto*****>
> Enviado: quarta-feira, 22 de dezembro de 2021 02:36
> Para: Filipe Moraes <dev_filip****@hotma*****>
> Cc: cloud****@lists***** <cloud****@lists*****>
> Assunto: Re: [CloudI] [examples] Error adding a compiled Erlang BEAM file path with an internal service implementation
>
> Hi Filipe,
>
> If you use the recent commit ([https://github.com/CloudI/CloudI/commit/03d4575a84416f9458207da9e95b694d1f1f769b](https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FCloudI%2FCloudI%2Fcommit%2F03d4575a84416f9458207da9e95b694d1f1f769b&data=04%7C01%7C%7C8b8d00d02a024d717d6508d9c50cfeab%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637757481888426710%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=8fMtxK46fUAezazerUxcaChUid928p7efmbOSBupvds%3D&reserved=0)) on the develop branch, you will be using the fix for this problem.
>
> The problem prevents the web interface from getting its view of the services. If too many requests occurred (5 (MaxR) within 5 minutes (MaxT)) the cloudi_service_api_requests service would be stopped instead of restarted due to the error.
>
> Best Regards,
> Michael
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Tuesday, December 21st, 2021 at 8:03 PM, Michael Truog <mjtru****@proto*****> wrote:
>
>> Hi Filipe,
>>
>> Thank you for reporting this problem. You have found a bug in the cloudi_service_api_requests JSON output. The rest of the stacktrace in the log output should confirm that. By that I mean the output after:
>> 2021-12-22T02:40:46.363937Z ERROR (cloudi_core_i_services_internal:867:handle_info/2:<0.1374.0>:cloudi at 9a82290a0570)
>> request error badarg
>> [{erlang,atom_to_binary,
>> ...
>>
>> That means this request works:
>> curl http://localhost:6464/cloudi/api/rpc/services.erl
>>
>> However, this request will fail, if you have added a service that uses a string value for module parameter:
>> curl http://localhost:6464/cloudi/api/rpc/services.json
>>
>> I will add a fix for this.
>>
>> Thanks,
>> Michael
>>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Tuesday, December 21st, 2021 at 7:28 PM, Filipe Moraes <dev_filip****@hotma*****> wrote:
>>
>>> Hi everybody,
>>>
>>> I'm trying [https://github.com/CloudI/CloudI/tree/v2.0.4/examples/hello_world_erlang](https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FCloudI%2FCloudI%2Ftree%2Fv2.0.4%2Fexamples%2Fhello_world_erlang&data=04%7C01%7C%7C8b8d00d02a024d717d6508d9c50cfeab%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637757481888436701%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=iNlv7Ho2yCoHVjkN2BQO8rzn2sOT0tZ9%2BMl79h6nTe0%3D&reserved=0) - section "To use a compiled Erlang BEAM file path with an internal service implementation".
>>>
>>> Following the documentation steps
>>>
>>>> $ cat << EOF > hello_world_erlang_beam.conf
>>>> [[{prefix, "/examples/"},
>>>> {module, "$PWD/ebin/hello_world_erlang.beam"}]]
>>>> EOF
>>>> $ curl -X POST -d @hello_world_erlang_beam.conf http://localhost:6464/cloudi/api/rpc/services_add.erl
>>>
>>> I get the UUID and service is up and running, but something stop working after an internal error occurs due calling atom_to_binary/2 with string parameter.
>>>
>>>> 2021-12-22T02:40:46.363937ZERROR (cloudi_core_i_services_internal:867:handle_info/2:<0.1374.0>:cloudi at 9a82290a0570)
>>>> request error badarg
>>>> [{erlang,atom_to_binary,
>>>> ["/workspace/clones/CloudI/CloudI/examples/hello_world_erlang/ebin/hello_world_erlang.beam",
>>>> utf8],
>>>> [{error_info,#{module => erl_erts_errors}}]},
>>>
>>> Service remains up and responding to requests, but service summary stop working.
>>>
>>> While I was writing this email I tried this (and things seems ok now):
>>>
>>> Edit .conf:
>>>
>>>> [[{prefix, "/examples/"},
>>>> {type, internal},
>>>> {module, hello_world_erlang}]]
>>>
>>> Add code path and service conf:
>>>
>>>> curl -X POST -d '"'`pwd`/ebin'"' http://localhost:6464/cloudi/api/rpc/code_path_add.erl
>>>> curl -X POST -d @hello_world_erlang.conf http://localhost:6464/cloudi/api/rpc/services_add.erl
>>>
>>> I'm not sure if this behavior is a bug... but it seems the doc contains wrong instructions.
>>>
>>> --
>>> Filipe Moraes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/cloudi-questions/attachments/20211222/7658fc06/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 19978 bytes
Desc: not available
URL: <https://lists.osdn.me/mailman/archives/cloudi-questions/attachments/20211222/7658fc06/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 31431 bytes
Desc: not available
URL: <https://lists.osdn.me/mailman/archives/cloudi-questions/attachments/20211222/7658fc06/attachment-0003.png>


More information about the cloudi-questions mailing list
Back to archive index