Starting projections on startup

I’m running the EventStore single node for testing with arguments: --mem-db --tcp-port=2111 --http-port=2113 --run-projections=all

However, none of the projections (except $users) actually starts. So then I reverse engineered how you are starting them through the web UI, and ended up adding some code like this to the process start code:


        using (var webClient = new WebClient())


            webClient.Credentials = new NetworkCredential("admin", "changeit");

            webClient.Headers.Add("Accept", "application/json");

            foreach (var projection in new[] { "$by_category", "$stream_by_category" })


                var url = string.Format("http://{0}:{1}/projection/{2}/command/enable", EventStoreIp,

                    EventStoreHttpPort, projection);

                var content = string.Format("{{\"msgTypeId\":241, \"name\":\"{0}\"}}", projection);

                webClient.UploadString(url, content);



This seems pretty hacky… is there a better way to enable projections on startup? I just need the category one running for now.

Also, I notice that when I subscribe to a category stream ($ce-*), with no credentials set, it gives me an access error, but other streams that I create/read/append don’t seem to require credentials. I am curious about why that is.



By default you need to be the admin user (admin:changeit) to subscribe to system streams.

See default acls here

By default system streams require admin access

Alright, thanks. So, any way to start projections on startup rather than having to post enable to them?

No however once they are enabled they stay enabled.

There is iirc also a method in the client API wrapping this call

They don’t stay enabled when you run --mem-db.

Once you have enabled them they will stay enabled on that db. Memdb is obviously a new db every time.

We really don’t want to start all of them by default as most systems will never use them

Can I start it as non-memory once, and then have it subsequently start with in-memory? I only really need the $ce projection.

Nope. You would have to start it then as the db gets thrown away every time

Well my hacky way of enabling the projections work on my machine, but it doesn’t work when the build agent runs it, so my integration tests fail.

Assembly Initialization method InfrastructureTests.EventStore.TestClasses.InMemoryEventStore.SetupInMemoryEventStore threw exception. System.Net.WebException: System.Net.WebException: The remote server returned an error: (503) Server Unavailable… Aborting test execution.

I double-checked that I have the URL ACL setup.

Reserved URL : http://+:2113/

User: builduser

Listen: Yes

I even added a 10s delay before trying.

Is it windows? Have you added an acl for 2113 that whatever use it runs under is allowed to listen there?

Yes, and I have setup the ACL.

Reserved URL : http://+:2113/

User: builduser

Listen: Yes

Try starting up manually as the user you are running under, it sounds like http is not bound.

It runs without issue as the build user on the build server. Also the tests pass when I comment out the lines that enable the projections. Except the test which listens to a projection.

I got it working by changing the listening ports. I checked netstat, and didn’t see 2113 being used, but I guess it is.