Reinitialize PEngines Instance Completely without Exiting SWI-Prolog?

When I am in development mode, I frequently make changes to several source files. Currently, in order to reinitialize my PEngines instance, I exit the SWI-Prolog console completely and restart SWI-Prolog. This is the easiest way for me to reset my environment, because I have predicates in my swipl.ini file that need to be executed to set up and run the PEngines server. Now that I am about to duplicate my local PEngines instance onto my server box, I’d like to streamline that process to make my life easier.

Is there a way to do this from within SWI-Prolog? Something that would duplicate the behavior of running SWI-Prolog from scratch so that it would clear out nearly everything and then re-execute the initialization file? That would save me a lot of trouble when compare to the process of completely exiting and restarting SWI-Prolog each time.

If not, how are those of you with live PEngines instances in the cloud restarting your instances when you want a fresh start after changing a slew of source files?

In most cases, and especially when using modules all over the place, simply run ?- make.. That will reload all changed files. That should typically do the job. There are some exceptions, one being term/goal expansion rules that you change. The system doesn’t keep track where they are used, so a restart is the only option. You may also need to be careful about initialization directives that change the environment to make sure you can run them twice.

For me, when doing application development, restarting fresh is rare and I easily find myself working in the same instance the whole day.

Working in swipl.ini is probably not a good idea. It is meant to tweak the Prolog environment a bit to support development such as setting up command line history, the editor to use, etc.

2 Likes

Thanks Jan. I’ll try that.