Running SG as a service on EC2???

83 views
Skip to first unread message

Todd Freese

unread,
Jan 27, 2015, 3:55:05 PM1/27/15
to mobile-c...@googlegroups.com
I am trying to setup SG as a service on EC2 running Red Hat Enterprise Linux Server release 7.0.

Here is the shell command I am using:

sudo ./sync_gateway_service_install.sh --runas=ec2-user --runbase=/home/ec2-user/sync_gateway --srccfgdir=/home/ec2-user/sync_gateway --srccfgname=config.json --cfgpath=/home/ec2-user/sync_gateway/config.json --logsdir=/home/ec2-user/sync_gateway/logs


And here is the error I'm getting.


ERROR: Unsupported RedHat/CentOS Version "7.0"


Does not service install script need updating for 7.0?


Todd

ajres

unread,
Jan 27, 2015, 4:11:03 PM1/27/15
to mobile-c...@googlegroups.com
Support for Centos 7 has been added for Sync gateway 1.0.4.

Centos 7 uses Systemd for init scripts, not upstart.

The updated script sync_gateway_service_install.sh and the Systemd template are available on master in the Sync Gateway github repo.

The supported configuration options have been updated:

sync_gateway_service_install.sh
    -h --help
    --runas=<The user account to run sync_gateway as; default (sync_gateway)>
    --runbase=<The directory to run sync_gateway from; defaut (/home/sync_gateway)>
    --sgpath=<The path to the sync_gateway executable; default (/opt/couchbase-sync-gateway/bin/sync_gateway)>
    --cfgpath=<The path to the sync_gateway JSON config file; default (/home/sync_gateway/sync_gateway.json)>
    --logsdir=<The path to the log file direcotry; default (/home/sync_gateway/logs)>


Todd Freese

unread,
Jan 27, 2015, 4:48:02 PM1/27/15
to mobile-c...@googlegroups.com
Can I just copy over a new service directory from master, but still run the 1.0.3 binary for SG?

This is on a production server, so I would rather run 1.0.3 which we used for all our release testing.

Todd

ajres

unread,
Jan 28, 2015, 10:32:32 AM1/28/15
to mobile-c...@googlegroups.com
Yes, you should be able to copy over the service directory from master and use it with 1.0.3.

The following options are no longer supported:

--srccfgdir=/home/ec2-user/sync_gateway --srccfgname=config.json

But the templates are copied from the relative path 'script_templates', so should find the templates from the SG install path.

If you have any issues let us know.

Andy

Todd Freese

unread,
Jan 28, 2015, 11:46:35 AM1/28/15
to mobile-c...@googlegroups.com
Why does it need the script_templates? Seems like most people using this to deploy to production is going to have their own config.json file. Are the templates needed for something other than a starting config?

Todd

ajres

unread,
Jan 28, 2015, 11:57:56 AM1/28/15
to mobile-c...@googlegroups.com
The script templates are init script templates, not Sync Gateway config templates.

We have init script templates for Redhat/Centos 6 (Upstart), Ubuntu 12/14 (Upstart), Centos 7 (Systemd), MAC OS X (plist)

The service will install the examples/serviceconfig.json as a base configuration that you can replace with specific environment config.

We would welcome any feedback, especially any features that would better support production deployments.

Andy

Todd Freese

unread,
Jan 28, 2015, 12:31:13 PM1/28/15
to mobile-c...@googlegroups.com
So it looks like it configed the service.... but when I run:

sudo systemctl start sync_gateway.service


I get:

Job for sync_gateway.service failed. See 'systemctl status sync_gateway.service' and 'journalctl -xn' for details.


If I run systemctl status sync_gateway.service

I get:

sync_gateway.service - Couchbase Sync Gateway server

   Loaded: loaded (/usr/lib/systemd/system/sync_gateway.service; enabled)

   Active: failed (Result: exit-code) since Wed 2015-01-28 12:27:16 EST; 4s ago

  Process: 17004 ExecStartPre=/bin/mkdir -p /home/ec2-user/sync_gateway/logs (code=exited, status=1/FAILURE)


I confirmed that /home/ec2-user/sync_gateway/logs exists and has the correct permissions.


Any ideas?


Todd

ajres

unread,
Jan 28, 2015, 12:49:28 PM1/28/15
to mobile-c...@googlegroups.com
Is there is any additional information in  /var/log/messages, if yes, can you paste it here or if very large add to a gist or pastebin and link here.

Todd Freese

unread,
Jan 28, 2015, 1:00:23 PM1/28/15
to mobile-c...@googlegroups.com
Figured it out. For some reason it did not like running as the couch base user. When I changed it to ec2-user, it started right up.

Thanks for your help.

One thing that would be nice would be the ability to pass in a config.json file when you run the service script. Otherwise the script overwrites your config with a sample config. Not a big deal, but I would think most people using this script would already have a working config.json file. At least for setting up for production servers.

Todd

ajres

unread,
Jan 28, 2015, 1:50:06 PM1/28/15
to mobile-c...@googlegroups.com
Thanks for the feedback, I have created a ticket for the external config enhancement

Andy

Todd Freese

unread,
Jan 28, 2015, 2:22:11 PM1/28/15
to mobile-c...@googlegroups.com
Final follow up.

The reason for why the couchbase user did not work was simple. That user did not have permissions to log directory which was in the home directory of another user.

Todd
Reply all
Reply to author
Forward
0 new messages