Search code examples
ubuntuservicestartupcouchbase-sync-gateway

Start sync gateway service when system restarts


I start the sync gateway server from command line like this:

$ ./sync_gateway_service_install.sh

But I have to do this every time I reboot the server. Is there any way to make this script run at server start up? I'm running Ubuntu 14.04.1 on my server.


Solution

  • Found the solution. The problem was Sync Gateway service was going to start before Couchbase Server was started. To solve this issue edit the couchbase_init.d file as following:

    $ nano /opt/couchbase/etc/couchbase_init.d

    look for start() { section and change it from this:

        errcode=$?
        return $errcode
    

    to this:

       errcode=$?
       sleep 20
       initctl emit couchbase-server-started
       return $errcode
    

    Then edit the sync-gateway.conf file

    $ nano /etc/init/sync_gateway.conf
    

    and change this line:

        start on runlevel [2345]
    

    to this:

        start on runlevel [2345] and couchbase-server-started
    

    That will start the sync-gateway service after Couchbase server is started.