Skip to content

Commit

Permalink
Update readme for running on local. Add command line arg parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Sep 20, 2021
1 parent b3ad9c9 commit d6969e0
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"@nuxtjs/tailwindcss": "^4.2.1",
"postcss": "^8.3.6"
}
}
}
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
"main": "index.js",
"scripts": {
"dev": "node index.js",
"start": "node index.js",
"client": "cd client && npm install --production && npm run generate",
"prod": "npm run client && npm install && node prod.js"
"prod": "npm run client && npm install --production && node prod.js",
"start": "node prod.js"
},
"author": "advplyr",
"license": "ISC",
"dependencies": {
"archiver": "^5.3.0",
"axios": "^0.21.1",
"bcryptjs": "^2.4.3",
"command-line-args": "^5.2.0",
"cookie-parser": "^1.4.5",
"express": "^4.17.1",
"express-fileupload": "^1.2.1",
Expand Down
22 changes: 18 additions & 4 deletions prod.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
const optionDefinitions = [
{ name: 'config', alias: 'c', type: String },
{ name: 'audiobooks', alias: 'a', type: String },
{ name: 'metadata', alias: 'm', type: String },
{ name: 'port', alias: 'p', type: String }
]

const commandLineArgs = require('command-line-args')
const options = commandLineArgs(optionDefinitions)

const Path = require('path')
process.env.TOKEN_SECRET = '09f26e402586e2faa8da4c98a35f1b20d6b033c6097befa8be3486a829587fe2f90a832bd3ff9d42710a4da095a2ce285b009f0c3730cd9b8e1af3eb84df6611'
process.env.NODE_ENV = 'production'

const server = require('./server/Server')
global.appRoot = __dirname

const PORT = process.env.PORT || 3333
const CONFIG_PATH = process.env.CONFIG_PATH || Path.resolve('config')
const AUDIOBOOK_PATH = process.env.AUDIOBOOK_PATH || Path.resolve('audiobooks')
const METADATA_PATH = process.env.METADATA_PATH || Path.resolve('metadata')
var inputConfig = options.config ? Path.resolve(options.config) : null
var inputAudiobook = options.audiobooks ? Path.resolve(options.audiobooks) : null
var inputMetadata = options.metadata ? Path.resolve(options.metadata) : null

const PORT = options.port || process.env.PORT || 3333
const CONFIG_PATH = inputConfig || process.env.CONFIG_PATH || Path.resolve('config')
const AUDIOBOOK_PATH = inputAudiobook || process.env.AUDIOBOOK_PATH || Path.resolve('audiobooks')
const METADATA_PATH = inputMetadata || process.env.METADATA_PATH || Path.resolve('metadata')

console.log('Config', CONFIG_PATH, METADATA_PATH, AUDIOBOOK_PATH)

Expand Down
15 changes: 15 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ Built to run in Docker for now (also on Unraid server Community Apps)
docker run -d -p 1337:80 -v /audiobooks:/audiobooks -v /config:/config -v /metadata:/metadata --name audiobookshelf --rm advplyr/audiobookshelf
```

## Running on your local

```bash
git clone https://github.com/advplyr/audiobookshelf.git
cd audiobookshelf

# All paths default to root directory. Config path is the database.
# Directories will be created if they don't exist
# Paths are relative to the root directory, so "../Audiobooks" would be a valid path
npm run prod -- -p [PORT] --audiobooks [AUDIOBOOKS_PATH] --config [CONFIG_PATH] --metadata [METADATA_PATH]

# You only need to use `npm run prod` the first time, after that use `npm run start`
npm run start -- -p [PORT] --audiobooks [AUDIOBOOKS_PATH] --config [CONFIG_PATH] --metadata [METADATA_PATH]
```

## Contributing

Feel free to help out

0 comments on commit d6969e0

Please sign in to comment.