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

Can I restart the application from within a plug-in? #19

Closed
richardeakin opened this issue May 5, 2016 · 4 comments
Closed

Can I restart the application from within a plug-in? #19

richardeakin opened this issue May 5, 2016 · 4 comments

Comments

@richardeakin
Copy link

I've got a python script that I want to run before our application starts up in the morning that downloads and caches new content from our CMS. I'm thinking that the easiest way to reload after this happens is to restart the application. Is there a way to send a command to AMPM to do this? I realize I could call App::quit() from within C++ and rely on the heartbeat checker to cause a restart, but this feels a bit hacky.

Side question: how would you recommend running the python script? It doesn't look like a can run a "preLaunchCommand", although I think I can get by with a "postLaunchCommand", letting the app run in the meantime, then restarting afterwards.

Thanks for any help.. and really enjoying using this tool that you've created.

@LRitesh
Copy link
Contributor

LRitesh commented May 6, 2016

Josh might have a better answer once he's back from vacation, but one way to relaunch your app would be to save a new version of "ampm-restart.json" after loading new content. Ampm will constantly watch this file for changes, and will relaunch the app whenever it saves.

@endquote
Copy link
Member

endquote commented May 8, 2016

We have a very similar situation on a current project. We have a node script which will download content from a CMS on some schedule. The app should restart when that's done, but the downloader tool doesn't really talk to ampm or the app.

Most likely we'll have the downloader run at some specific time and use the ampm restartSchedule feature to restart the app at some time after that, when we're reasonably sure the first tool has completed.

But: adding some feature by which an app could request its own restart isn't a bad idea. And Ritesh's suggestion would be a current way to do it without ampm code changes.

@endquote
Copy link
Member

Actually, a plugin can $$persistence.restartApp().

I'm adding a documented restart feature anyway, though.

@richardeakin
Copy link
Author

(..back from vacation..)

Just wanted to mention that @endquote we ended up doing the same thing you are doing - we refresh content first thing in the morning, then run AMPM once that process is finished. Simple solution, drawback being that we couldn't (easily) update the content while the app is running, but not the end of the world.

Probably next project I'll look to see how I can make the app triger a $persistence.restartApp(), as that seems like a pretty clean solution to me.

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

3 participants