Skip to content

send Message before indexing with "set projectsEnabled = true" if run… #1682

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

Merged
merged 1 commit into from
Jul 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/org/opensolaris/opengrok/index/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.opensolaris.opengrok.configuration.Configuration;
import org.opensolaris.opengrok.configuration.Project;
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
import org.opensolaris.opengrok.configuration.messages.Message;
import org.opensolaris.opengrok.history.HistoryException;
import org.opensolaris.opengrok.history.HistoryGuru;
import org.opensolaris.opengrok.history.Repository;
Expand Down Expand Up @@ -582,6 +583,18 @@ public static void main(String argv[]) {
System.exit(1);
}

// If the webapp is running with a config that does not contain
// 'projectsEnabled' property (case of upgrade or transition
// from project-less config to one with projects), set the property
// using a message so that the 'project/indexed' messages
// emitted during indexing do not cause validation error.
if (addProjects && host != null && port > 0) {
Message m = Message.createMessage("config");
m.addTag("set");
m.setText("projectsEnabled = true");
m.write(host, port);
Copy link
Contributor

@tulinkry tulinkry Jul 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fails will the index process continue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If e.g. write() throws exception, It will stop.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..which is good I think as it will avoid surprise at the end of the indexing (if the webapp is permanently down).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not because that completely prevents you to prepare the configuration offline.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the host/port is not set the message will not be sent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my bad. Let's merge.

}

// Get history first.
getInstance().prepareIndexer(env, searchRepositories, addProjects,
defaultProjects,
Expand Down