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

Cleanly exit IOC when stopping IOC execution #2

Open
gguyotte opened this issue Dec 16, 2022 · 3 comments
Open

Cleanly exit IOC when stopping IOC execution #2

gguyotte opened this issue Dec 16, 2022 · 3 comments

Comments

@gguyotte
Copy link

Currently, stopping an IOC only terminates the IOC process, but does not allow for that IOC to gracefully shutdown. In some cases, it would be preferable to issue the 'exit()' command at the EPICS shell prior to forcefully terminating the process.

In my experience this is necessary for certain IOCs which are controlling hardware, e.g. camera hardware. I have a concrete example of a failure we experience at SNS. A camera IOC makes a connection to the SDK/API supplied as a shared library by the camera vendor (ANDOR). If the connection is not closed properly, the next attempt to connect to the camera will fail. Issuing the exit() command at the EPICS shell would allow the opportunity for the IOC to 'clean up' by closing the camera instance properly via the vendor API.

@coretl
Copy link
Contributor

coretl commented Dec 19, 2022

This sounds like a useful addition, I never added it because of the complexity of having to work out if the exit had succeeded and CTRL-X it if it didn't. Can you think of a way to do this? Happy to accept a PR for this behaviour.

@gguyotte
Copy link
Author

gguyotte commented Dec 22, 2022 via email

@coretl
Copy link
Contributor

coretl commented Jan 3, 2023

My thinking is that we could have a timeout PV rather than any positive acknowledgement of exit success. If the timeout PV value is 0, the current behavior is in charge, otherwise emit exit() to the IOC shell, wait out the timeout, and then bang CTRL-X.

The only issue with this approach is that exit() will cause the IOC to restart if auto-restart is on, so we'd have to detect if it restarted during the timeout so we didn't double restart it

One thing I haven't worked out is how we can emit characters to the IOC shell from the .st file.....not sure if printf() would be the best mechanism for that, or is there something more clever.

You can do something like https://github.com/dls-controls/procServControl/blob/fb8423c4fc6d51f1ce3954f88aa13fe800fc8ae6/procServControlApp/src/procServControl.st#L343-L360

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