snet-daemon icon indicating copy to clipboard operation
snet-daemon copied to clipboard

Make etcd internally configured on free network ports

Open ferrouswheel opened this issue 6 years ago • 2 comments

If you want to run multiple snetd instances, the etcd instances spawned by snetd will have their ports clash.

You can get around this by explicitly configuring a different port, e.g.

{
...
"payment_channel_storage_server": {
    "id": "storage-3",
    "host" : "127.0.0.1",
    "client_port": 2383,
    "peer_port": 2384,
    "token": "unique-token",
    "cluster": "storage-3=http://127.0.0.1:2384",
    "data_dir": "etcd/storage-data-dir-3.etcd",
    "enabled": true
}}

However this is error prone. Specifically you have to manually choose two free ports, and you have to make sure the cluster string is pointing at the peer port.

It'd be nice if there was a way for snetd to automatically configure it's internal etcd server. If the etcd instance is only used by one snetd instance, then this extra configuration should be hidden.

(I understand the reason for the extra config, but for simple use-cases without replication, it'd be nice to keep all these details internal to the app)

There is also an in-memory etcd storage, which might be an alternative approach, but I'm not sure of how that would impact MPE behaviour if snetd was restarted.

ferrouswheel avatar Jan 30 '19 21:01 ferrouswheel

There is also an in-memory etcd storage, which might be an alternative approach, but I'm not sure of how that would impact MPE behaviour if snetd was restarted.

In-memory etcd storage is not persisted to disk, so after daemon shutdown all information about payments will be lost. It is for testing purposes only.

vsbogd avatar Jan 31 '19 06:01 vsbogd

I think to make it less error prone we can generate random token automatically if it is not explicitly set in configuration. It will prevent the situation when different daemon instances use alien etcd server. @stellarspot could you please advise if it will work?

And we can find couple of free ports for etcd automatically again if there is no explicit configuration.

vsbogd avatar Jan 31 '19 06:01 vsbogd