##// END OF EJS Templates
added latest changes
added latest changes

File last commit:

r5644:09e63857 default
r5658:a109f5ac merge default
Show More
tools-cli.rst
582 lines | 15.5 KiB | text/x-rst | RstLexer

|RCT| CLI

The commands available with |RCT| can be split into three categories:

  • Remotely executable commands that can be run from your local machine once you have your connection details to |RCE| configured.
  • Locally executable commands the can be run on the server to carry out general maintenance.
  • Local configuration commands used to help set up your |RCT| configuration.

rhodecode-list-instances

Use this command to list the instance details configured in the :file:`/etc/rhodecode/conf/.rhoderc` file.

$ ./rcstack cli cmd rhodecode-list-instances --config=/etc/rhodecode/conf/.rhoderc
[instance:production] - Config only
API-HOST: https://some.url.com
API-KEY:  some.auth.token

[instance:development] - Config only
API-HOST: http://some.ip.address
API-KEY:  some.auth.token

rhodecode-tools

Use |RCT| to setup automation, run the indexer, and install extensions for your |RCE| instances. Options:

Example usage:

$ rhodecode-tools --apikey=key --apihost=http://rhodecode.server \
    --save-config

rhodecode-api

The RhodeCode API lets you connect to |RCE| and carry out management tasks from a remote machine, for more information about the API, see the :ref:`api`. To pass arguments on the command-line use the method:option syntax.

Example usage:

# Run the get_repos API call and sample output
$ rhodecode-api --instance-name=enterprise-1 create_repo \
    repo_name:brand-new repo_type:hg description:repo-desc

{
  "error": null,
  "id": 1110,
  "result": {
    "msg": "Created new repository `brand-new`",
    "success": true,
    "task": null
  }
}

Options:

rhodecode-cleanup-gists

Use this to delete gists within |RCE|. Options:

Example usage:

# Clean up gists related to an instance
$ rhodecode-cleanup-gists --instance-name=enterprise-1
Scanning for gists in /home/brian/repos/.rc_gist_store...
preparing to remove [3] found gists

# Clean up corrupted gists in an instance
$ rhodecode-cleanup-gists --instance-name=enterprise-1 --corrupted
Scanning for gists in /home/brian/repos/.rc_gist_store...
preparing to remove [2] found gists
the following gists will be archived:
  * EXPIRED: BAD METADATA        | /home/brian/repos/.rc_gist_store/5
  * EXPIRED: BAD METADATA        | /home/brian/repos/.rc_gist_store/8FtC
are you sure you want to archive them? [y/N]: y
removing gist /home/brian/repos/.rc_gist_store/5
removing gist /home/brian/repos/.rc_gist_store/8FtCKdcbRKmEvRzTVsEt

rhodecode-cleanup-repos

Use this to manage |repos| and |repo| groups within |RCE|. Options:

Example usage:

# create a .rhoderc file in your host config directory (in :file:`config/_shared/.rhoderc`):

[instance:rcstack-instance]
api_host = http://rhodecode:10020
api_key = <API_KEY>
repo_dir = /var/opt/rhodecode_repo_store

# Run rcstack cli
./rcstack cli cmd rhodecode-cleanup-repos --instance-name=rcstack-instance --config=/etc/rhodecode/conf/.rhoderc

checking if config files needs bootstrapping
Scanning for repositories in /var/opt/rhodecode_repo_store...

the following repositories will be deleted completely:
* REMOVED: 2015-08-05 00:23:18 | /var/opt/rhodecode_repo_store/rm__20150805_002318_831
* REMOVED: 2015-08-04 01:22:10 | /var/opt/rhodecode_repo_store/rm__20150804_012210_336
are you sure you want to remove them? [y/N]:

# Clean up repos older than 1 year
./rcstack cli cmd rhodecode-cleanup-repos --instance-name=rcstack-instance --config=/etc/rhodecode/conf/.rhoderc --older-than=365d

checking if config files needs bootstrapping
Scanning for repositories in /var/opt/rhodecode_repo_store...
preparing to remove [343] found repositories older than 365 days

# clean up repos older than 3 days
./rcstack cli cmd rhodecode-cleanup-repos --instance-name=rcstack-instance --config=/etc/rhodecode/conf/.rhoderc --older-than=3d

checking if config files needs bootstrapping
Scanning for repositories in /var/opt/rhodecode_repo_store...
preparing to remove [3] found repositories older than 3 days

rhodecode-config

Use this to create or update a |RCE| configuration file on the local machine.

# Create a new config file
$ rhodecode-config --filename=dev.ini
Wrote new config file in /Users/user/dev.ini

# Update config value for given section:
$ rhodecode-config --update --filename=prod.ini [handler_console]level=INFO

$ rhodecode-config --filename=dev.ini --show-defaults
lang=en
cpu_number=4
uuid=<function <lambda> at 0x10d86ac08>
license_token=ff1e-aa9c-bb66-11e5
host=127.0.0.1
here=/Users/brian
error_aggregation_service=None
database_url=sqlite:///%(here)s/rhodecode.db?timeout=30
git_path=git
http_server=waitress
port=5000

rhodecode-extensions

The rcextensions since version 4.14 are now shipped together with |RCE| please check the using :ref:`integrations-rcextensions` section.

rhodecode-gist

Use this to create, list, show, or delete gists within |RCE|. Options:

Example usage:

# List the gists in an instance
(venv)brian@ubuntu:~$ rhodecode-gist --instance-name=enterprise-1 list
{
  "error": null,
  "id": 7102,
  "result": [
    {
      "access_id": "2",
      "content": null,
      "created_on": "2015-01-19T12:52:26.494",
      "description": "A public gust",
      "expires": -1.0,
      "gist_id": 2,
      "type": "public",
      "url": "http://127.0.0.1:10003/_admin/gists/2"
    },
    {
      "access_id": "7gs6BsSEC4pKUEPLz5AB",
      "content": null,
      "created_on": "2015-01-19T11:27:40.812",
      "description": "Gist testing API",
      "expires": -1.0,
      "gist_id": 1,
      "type": "private",
      "url": "http://127.0.0.1:10003/_admin/gists/7gs6BsSEC4pKUEPLz5AB"
    }
  ]
}

# delete a particular gist
# You use the access_id to specify the gist to delete
(venv)brian@ubuntu:~$ rhodecode-gist delete 2  --instance-name=enterprise-1
{
  "error": null,
  "id": 6284,
  "result": {
    "gist": null,
    "msg": "deleted gist ID:2"
  }
}

# cat a file and pipe to new gist
# This is if you are using virtualenv
(venv)$ cat ~/.rhoderc | rhodecode-gist --instance-name=enterprise-1 \
    -d '.rhoderc copy' create

{
  "error": null,
  "id": 5374,
  "result": {
    "gist": {
      "access_id": "7",
      "content": null,
      "created_on": "2015-01-26T11:31:58.774",
      "description": ".rhoderc copy",
      "expires": -1.0,
      "gist_id": 7,
      "type": "public",
      "url": "http://127.0.0.1:10003/_admin/gists/7"
    },
    "msg": "created new gist"
  }
}

# Cat a file and pipe to gist

$ cat ~/.rhoderc | ./rcstack cli cmd rhodecode-gist --instance-name=rcstack-instance --config=/etc/rhodecode/conf/.rhoderc -d '.rhoderc copy' create
{
  "error": null,
  "id": 9253,
  "result": {
    "gist": {
      "access_id": "4",
      "acl_level": "acl_public",
      "content": null,
      "created_on": "2015-08-20T05:54:11.250",
      "description": ".rhoderc copy",
      "expires": -1.0,
      "gist_id": 4,
      "modified_at": "2015-08-20T05:54:11.250",
      "type": "public",
      "url": "http://127.0.0.1:10000/_admin/gists/4"
    },
    "msg": "created new gist"
  }
}

rhodecode-index

More detailed information regarding setting up the indexer is available in the :ref:`indexing-ref` section. Options:

Example usage:

# Create the indexing mapping file
$ ./rcstack cli cmd rhodecode-index --instance-name=rcstack-instance --config=/etc/rhodecode/conf/.rhoderc --create-mapping search_mapping.ini

# Run the indexer
$ ./rcstack cli cmd rhodecode-index --instance-name=rcstack-instance --config=/etc/rhodecode/conf/.rhoderc

# Run indexer based on search_mapping.ini file using rhodecode-tools virtualenv
(venv)$ rhodecode-index --instance-name=rcstack-instance

# Index from the command line without creating
# the .rhoderc file
$ rhodecode-index --apikey=key --apihost=http://rhodecode.server --instance-name=rcstack-instance --save-config

rhodecode-setup-config

Use this command to create the ~.rhoderc file required by |RCT| to access remote instances.

(venv)$ rhodecode-setup-config --instance-name=tea api_host=URL api_key=xyz
Config not found under /Users/username/.rhoderc, creating a new one
Wrote new configuration into /Users/username/.rhoderc