Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@onServerInit vs @onWorkerStart #17

Closed
trikko opened this issue Aug 1, 2022 · 6 comments
Closed

@onServerInit vs @onWorkerStart #17

trikko opened this issue Aug 1, 2022 · 6 comments

Comments

@trikko
Copy link

trikko commented Aug 1, 2022

I think you want to run this initialization inside a function marked with UDA @onWorkerStart .

adi = new ADI(expandTilde("~/.adi"));

Functions marked with @OnServerInit are executed just one time by the daemon not by the process that reply to your http request.

// This function will be called for each worker
@onWorkerStart void yourInitFunction()
{
    adi = new ADI(expandTilde("~/.adi"));

    if (!adi.isMachineProvisioned()) {
        stderr.write("Machine requires provisioning... ");
        adi.provisionDevice(rinfo);
        stderr.writeln("done !");
    } else {
        // adi.getRoutingInformation(rinfo);
        rinfo = 0;
    }
}
@Dadoum
Copy link
Owner

Dadoum commented Aug 1, 2022

Yes but it only needs to be run one time at the beginning. Except if I did not understand how works workers

@trikko
Copy link
Author

trikko commented Aug 1, 2022

Workers are separated processes, started by the daemon.

When a worker start @onWorkerStart is called. Just one time for each worker.

@Dadoum
Copy link
Owner

Dadoum commented Aug 1, 2022

That's problematic since it seems that I can only use one ADI handle at a time, or it will break. How can I do.

When I compare my old archttp implementation with the new experimental serverino one, I can see that the older one always respond with the needed data while the serverino will fail and break after few requests.

Tested by running this command to stress test the server:

curl 127.0.0.1:6969 & curl 127.0.0.1:6969 &curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 & curl 127.0.0.1:6969 &

@trikko
Copy link
Author

trikko commented Aug 1, 2022

That's problematic since it seems that I can only use one ADI handle at a time, or it will break. How can I do.

But they live in different processes. There is no data shared between responders. Each responder is completly isolated. If you run 4 responder, you're running 4 different instances each one with a single ADI handle. Is this a problem?

@Dadoum
Copy link
Owner

Dadoum commented Aug 1, 2022

I don't really know how ADI exactly works. What I described is not related to the location of the ADI instructions (if they are in onServerInit or in onWorkerStart), it happens with both locations. The only thing I really know is that ADI functions break with the serverino version, and that ADI interracts with a file on the filesystem located at ~/.adi/adi.pb.

@Dadoum
Copy link
Owner

Dadoum commented Aug 8, 2022

Switching back to archttp for now.

@Dadoum Dadoum closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants