Sync gateway on ubuntu

I couldn’t find instructions on administering the sync gateway on ubuntu. I guessed a few things, basically this:

wget http://packages.couchbase.com/releases/couchbase-sync-gateway/1.2.1/couchbase-sync-gateway-community_1.2.1-4_x86_64.deb
sudo dpkg -i couchbase-sync-gateway couchbase-sync-gateway-community_1.2.1-4_x86_64.deb

But it started immediately, and now I can’t stop it. Killing the process just spawns another one. What’s going on?

I’ve tried

sudo su - sync_gateway
service --status-all

But there’s no service called sync_gateway

@nick-couchbase

The service wrapper will auto spawn sync_gateway if it’s process terminates other than by a controlled stop.

The command on ubuntu to stop the sync_gateway service should be:

$ sudo service sync_gateway stop

try:
sudo start sync_gateway
&
sudo stop sync_gateway

Thanks, sudo service sync_gateway stop worked.

I want to run 2 gateways on a machine. Neither of which use the default installation. Can I use the sync_gateway_service_install.sh script to do this? Do I need to uninstall the sync_gateway that got installed by default, or do I just reconfigure it?

To run multiple SG instances on the same machine you will need to bind each instance to different ports (and/or different interface cards, with different IP’s) and separate log output.

To test this manually, stop the default SG service.

Then create two SG config files binding to different ports e.g.:

{
	"log": ["*"],
        "adminInterface":"127.0.0.1:4985",
        "interface":":4984",
        "databases": {
		"db": {
			"server": "walrus:",
			"bucket": "default",
			"users": {
				"GUEST": {"disabled": false, "admin_channels": ["*"]}
			}
		}
        }
}

and

{
	"log": ["*"],
        "adminInterface":"127.0.0.1:4995",
        "interface":":4994",
        "databases": {
		"db": {
			"server": "walrus:",
			"bucket": "default",
			"users": {
				"GUEST": {"disabled": false, "admin_channels": ["*"]}
			}
		}
        }
}

Open two terminal windows and run sync_gateway from both using a different config file:

$ <PATH_TO_SG_BIN_DIR>/sync_gateway config-A.json

and

$ <PATH_TO_SG_BIN_DIR>/sync_gateway config-B.json

I’ll see if it’s possible to run two SG services on one server and post instructions here.

Thanks, I understand about the ports and have run 2 quite happily on my laptop. But installing 2 as services on ubuntu is where I’m struggling. The sync_gateway_service_install.sh hard codes the service name as sync_gateway. First step was to change the script so that a service name can be passed in. But even using 2 different service names the 2nd instance won’t start. In the access log it just says process already running.

I have opened a GitHub issue to track this.

1 Like