|
| 1 | +% |
| 2 | +% This file is part of AtomVM. |
| 3 | +% |
| 4 | +% Copyright 2024 Paul Guyot <pguyot@kallisys.net> |
| 5 | +% |
| 6 | +% Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +% you may not use this file except in compliance with the License. |
| 8 | +% You may obtain a copy of the License at |
| 9 | +% |
| 10 | +% http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +% |
| 12 | +% Unless required by applicable law or agreed to in writing, software |
| 13 | +% distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +% See the License for the specific language governing permissions and |
| 16 | +% limitations under the License. |
| 17 | +% |
| 18 | +% SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later |
| 19 | +% |
| 20 | + |
| 21 | +-module(disterl). |
| 22 | + |
| 23 | +-export([start/0]). |
| 24 | + |
| 25 | +start() -> |
| 26 | + {ok, _KernelPid} = kernel:start(normal, []), |
| 27 | + {ok, _NetKernelPid} = net_kernel:start('atomvm@127.0.0.1', #{name_domain => longnames}), |
| 28 | + io:format("Distribution was started\n"), |
| 29 | + io:format("Node is ~p\n", [node()]), |
| 30 | + net_kernel:set_cookie(<<"AtomVM">>), |
| 31 | + io:format("Cookie is ~s\n", [net_kernel:get_cookie()]), |
| 32 | + register(disterl, self()), |
| 33 | + io:format( |
| 34 | + "This AtomVM node is waiting for 'quit' message, and this process is registered as 'disterl'\n" |
| 35 | + ), |
| 36 | + io:format("On an OTP node with long names distribution, run:\n"), |
| 37 | + io:format("erlang:set_cookie('atomvm@127.0.0.1', 'AtomVM').\n"), |
| 38 | + io:format("{disterl, 'atomvm@127.0.0.1'} ! quit.\n"), |
| 39 | + receive |
| 40 | + quit -> ok |
| 41 | + end. |
0 commit comments