0

After the schema.xml file creation, I want to restart the solr to reflect the newly created core. When restarting through command prompt, the solr gets restarted and everything works fine. But I want to do the restart through PHP code. I have used the below PHP code to restart, which outputs request timeout error (also getting Internal server error) also the solr is not restarted.

exec("solr restart -p 8983", $output, $return);

I am running PHP in IIS 6.x. Can anyone please suggest a solution.

Ba.Lal
  • 180
  • 2
  • 16
  • Check return values and error output. A shell command must not automatically work always, ever. Instead it is the duty of the caller to check return values, especially for error conditions. This is a requirement with your question especially as you write that "it does not work". As only you have the system at hand and the code you've posted does not contain error checks, you need to extend the example first and report back about the concrete error messages. For Everything else: Crystal Ball Debug Sessions are historically scheduled Fridays on Stackoverflow :). – hakre Jun 14 '17 at 10:59
  • I dont think its a duplicate. Here I want to execute the SOLR retstart though PHP. That the thing I need. I am getting "HTTP Error 500.0 - Internal Server Error" while executing the above code. – Ba.Lal Jun 14 '17 at 11:09
  • I did perfectly understood what you need, I just pointed out that this is just not the best form to ask that on a Q&A site. You can edit your question to reflect the error handling of the code so far (looks like still none, please see the linked duplicate to get an idea how it *could* look like, I posted it in good faith). Also you should make the error message part of your question (burying it in a comment below the question is hiding it a little). An internal server error 500 is always an invitation to look into the servers error log, it contains more information about the error. – hakre Jun 14 '17 at 11:15
  • Any particular reason why you can't just use the [CoreAdmin API](https://cwiki.apache.org/confluence/display/solr/CoreAdmin+API)? This for once will avoid you to restart Solr, which can cause downtime. And on the other hand, once you have the config files in place is the same thing as using the AdminUI. – Jorge Luis Jun 14 '17 at 12:46
  • In your case probably the web browser is not running as a user with enough privileges to restart a service (this is only done only by root or some other special user). Anyhow I still say that this is a really bad idea, you should use the CoreAdmin API. – Jorge Luis Jun 14 '17 at 15:23
  • @JorgeLuis, thanks for the suggestion. I didnt aware of this CoreAdmin API. Let me try. – Ba.Lal Jun 15 '17 at 06:08

0 Answers0