From e6ce76475086cc7fd5222bee9b97b8c1f8797f1c Mon Sep 17 00:00:00 2001 From: Mark Doeswijk Date: Tue, 19 Nov 2013 11:53:53 +0100 Subject: [PATCH 1/3] Added documentation for how to setup sinopia on a linux server --- SERVER.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 SERVER.md diff --git a/SERVER.md b/SERVER.md new file mode 100644 index 000000000..7fd9bde68 --- /dev/null +++ b/SERVER.md @@ -0,0 +1,51 @@ +This is mostly basic linux server configuration stuff but I felt it important to document and share the steps I took to get sinopia running permanently on my server. You will need root (or sudo) permissions for the following. + +## Running as a separate user +First create the sinopia user: +```bash +$ sudo adduser --disabled-login --gecos 'Sinopia NPM mirror' sinopia +``` + +You create a shell as the sinopia user using the following command: +```bash +$ sudo su sinopia +$ cd ~ +``` + +The 'cd ~' command send you to the home directory of the sinopia user. Make sure you run sinopia at least once to generate the config file. Edit it according to your needs. + +## Keeping sinopia running forever +We can use the node package called 'forever' to keep sinopia running all the time. +https://github.com/nodejitsu/forever + +First install forever globally: +```bash +$ sudo npm install -g forever +``` + +Make sure you've started sinopia at least once to generate the config file and write down the created admin user. You can then use the following command to start sinopia: +```bash +$ forever start `which sinopia` +``` + +You can check the documentation for more information on how to use forever. + +## Surviving server restarts +We can use crontab and forever together to restart sinopia after a server reboot. +When you're logged in as the sinopia user do the following: + +```bash +$ crontab -e +``` + +This might ask you to choose an editor. Pick your favorite and proceed. +Add the following entry to the file: +``` +@reboot /usr/bin/forever start /usr/lib/node_modules/sinopia/bin/sinopia +``` + +The locations may vary depending on your server setup. If you want to know where your files are you can use the 'which' command: +```bash +$ which forever +$ which sinopia +``` \ No newline at end of file From 558598c6be0c05e42eb5d87e07156a8dfc32b774 Mon Sep 17 00:00:00 2001 From: Mark Doeswijk Date: Tue, 19 Nov 2013 11:56:38 +0100 Subject: [PATCH 2/3] Added information about how to add a new user --- README.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8b0a90d1b..71155ef44 100644 --- a/README.md +++ b/README.md @@ -4,23 +4,23 @@ It allows you to have a local npm registry with zero configuration. You don't ha ## Use cases -1. Use private packages. - +1. Use private packages. + If you want to use all benefits of npm package system in your company without sending all code to the public, and use your private packages just as easy as public ones. See [using private packages](#using-private-packages) section for details. 2. Cache npmjs.org registry. - + If you have more than one server you want to install packages on, you might want to use this to decrease latency (presumably "slow" npmjs.org will be connected to only once per package/version) and provide limited failover (if npmjs.org is down, we might still find something useful in the cache). See [using public packages](#using-public-packages-from-npmjsorg) section for details. 3. Override public packages. - + If you want to use a modified version of some 3rd-party package (for example, you found a bug, but maintainer didn't accepted pull request yet), you can publish your version locally under the same name. - + See [override public packages](#override-public-packages) section for details. ## Installation @@ -47,6 +47,19 @@ $ npm set ca null When you start a server, it auto-creates a config file that adds one user (password is printed to stdout only once). +## Adding a new user + +There is no utility to add a new user but you can at least use node on the command-line to generate a password. You will need to edit the config and add the user manually. + +Start node and enter the following code replacing 'newpass' with the password you want to get the hash for. +```bash +$ node +> crypto.createHash('sha1').update('newpass').digest('hex') +'6c55803d6f1d7a177a0db3eb4b343b0d50f9c111' +> [CTRL-D] +``` + + ## Using private packages You can add users and manage which users can access which packages. @@ -66,13 +79,13 @@ If you want to use a modified version of some public package `foo`, you can just There's two options here: 1. You want to create a separate fork and stop synchronizing with public version. - + If you want to do that, you should modify your configuration file so sinopia won't make requests regarding this package to npmjs anymore. Add a separate entry for this package to *config.yaml* and remove `npmjs` from `proxy_access` list and restart the server. - + When you publish your package locally, you should probably start with version string higher than existing one, so it won't conflict with existing package in the cache. 2. You want to temporarily use your version, but return to public one as soon as it's updated. - + In order to avoid version conflicts, you should use a custom pre-release suffix of the next patch version. For example, if a public package has version 0.1.2, you can upload 0.1.3-my-temp-fix. This way your package will be used until its original maintainer updates his public package to 0.1.3. ## Compatibility From 9f2871f381ad42cecf82a35b8edc41de3e8e8849 Mon Sep 17 00:00:00 2001 From: Mark Doeswijk Date: Tue, 19 Nov 2013 13:26:32 +0100 Subject: [PATCH 3/3] Added listen all documentation --- SERVER.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SERVER.md b/SERVER.md index 7fd9bde68..c09a66855 100644 --- a/SERVER.md +++ b/SERVER.md @@ -14,6 +14,13 @@ $ cd ~ The 'cd ~' command send you to the home directory of the sinopia user. Make sure you run sinopia at least once to generate the config file. Edit it according to your needs. +## Listening on all addresses +If you want to listen to every external address set the listen directive in the config to: +``` +# you can specify listen address (or simply a port) +listen: 0.0.0.0:4873 +``` + ## Keeping sinopia running forever We can use the node package called 'forever' to keep sinopia running all the time. https://github.com/nodejitsu/forever