├── system.properties ├── .gitignore ├── Procfile ├── pom.xml ├── package.json ├── app.json ├── application.yml ├── bootstrap.js └── README.MD /system.properties: -------------------------------------------------------------------------------- 1 | java.runtime.version=13 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .env 3 | index.js 4 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: npm start 2 | worker: npm start 3 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.tfnico.dummy 5 | dummy-pom 6 | 1.0 7 | 8 | 9 | 10 | org.apache.maven.plugins 11 | maven-dependency-plugin 12 | 2.8 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lavalinkonheroku", 3 | "version": "3.3.2", 4 | "description": "A test heroku app to deploy your own lavalink server", 5 | "main": "bootstrap.js", 6 | "scripts": { 7 | "start": "node .", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "IamTheRealSami", 11 | "license": "MIT", 12 | "dependencies": { 13 | "node-fetch": "^2.6.1", 14 | "dotenv": "^8.2.0" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "git+https://github.com/IamTheRealSami/LavalinkOnHeroku.git" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/IamTheRealSami/LavalinkOnHeroku/issues" 22 | }, 23 | "homepage": "https://github.com/IamTheRealSami/LavalinkOnHeroku#readme" 24 | } 25 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Lavalink On Heroku", 3 | "description": "A Heroku app to deploy your own Lavalink server.", 4 | "keywords": [ 5 | "Lavalink", 6 | "lavalink", 7 | "discord-music-streaming", 8 | "LavalinkOnHeroku", 9 | "lavalink-on-heroku" 10 | ], 11 | "repository": "https://github.com/IamTheRealSami/LavalinkOnHeroku", 12 | "env": { 13 | "PASS": { 14 | "description": "Set this for authorization for your lavalink server. (default: youshallnotpass)", 15 | "value": "youshallnotpass" 16 | }, 17 | "APP_NAME": { 18 | "description": "The heroku app name to keep alive (retype the 'App name'). Leave empty to disable internal pinging.", 19 | "value": "your-app-name" 20 | } 21 | }, 22 | "buildpacks": [ 23 | { 24 | "url": "heroku/nodejs" 25 | }, 26 | { 27 | "url": "heroku/java" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /application.yml: -------------------------------------------------------------------------------- 1 | server: # REST and WS server 2 | port: DYNAMICPORT 3 | address: 0.0.0.0 4 | lavalink: 5 | server: 6 | password: "youshallnotpass" 7 | sources: 8 | youtube: true 9 | bandcamp: true 10 | soundcloud: true 11 | twitch: true 12 | vimeo: true 13 | mixer: true 14 | http: true 15 | local: false 16 | bufferDurationMs: 400 17 | youtubePlaylistLoadLimit: 6 # Number of pages at 100 each 18 | youtubeSearchEnabled: true 19 | soundcloudSearchEnabled: true 20 | gc-warnings: true 21 | #ratelimit: 22 | #ipBlocks: ["1.0.0.0/8", "..."] # list of ip blocks 23 | #excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink 24 | #strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch 25 | #searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing 26 | #retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times 27 | 28 | metrics: 29 | prometheus: 30 | enabled: false 31 | endpoint: /metrics 32 | 33 | sentry: 34 | dsn: "" 35 | # tags: 36 | # some_key: some_value 37 | # another_key: another_value 38 | 39 | logging: 40 | file: 41 | max-history: 5 42 | max-size: 5MB 43 | path: ./logs/ 44 | 45 | level: 46 | root: INFO 47 | lavalink: INFO -------------------------------------------------------------------------------- /bootstrap.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config(); 2 | const fs = require('fs') 3 | const https = require('https') 4 | 5 | let application = fs.readFileSync('./application.yml', 'utf8') 6 | 7 | if (process.env.PORT) { 8 | application = application.replace('DYNAMICPORT', process.env.PORT) 9 | } 10 | 11 | if (process.env.PASS) { 12 | application = application.replace('youshallnotpass', process.env.PASS) 13 | } 14 | fs.writeFileSync('./application.yml', application) 15 | 16 | const download = function (url, dest, cb) { //modified code from https://stackoverflow.com/a/22907134 17 | const file = fs.createWriteStream(dest); 18 | https.get(url, function (response) { 19 | response.pipe(file); 20 | console.log('Downloading Lavalink.jar...') 21 | file.on('finish', function () { 22 | console.log('Finished Downloading Lavalink.jar') 23 | file.close(cb); 24 | }); 25 | }).on('error', function (err) { 26 | fs.unlinkSync(dest); 27 | console.error(err) 28 | }); 29 | }; 30 | 31 | function startLavalink() { 32 | const spawn = require('child_process').spawn; 33 | const child = spawn('java', ['-jar', 'Lavalink.jar']) 34 | 35 | child.stdout.setEncoding('utf8') 36 | child.stderr.setEncoding('utf8') 37 | 38 | child.stdout.on('data', (data) => { 39 | console.log(data); 40 | }); 41 | 42 | child.stderr.on('data', (data) => { 43 | console.error(data); 44 | }); 45 | 46 | child.on('error', (error) => { 47 | console.error(error); 48 | }); 49 | 50 | child.on('close', (code) => { 51 | console.log(`Lavalink exited with code ${code}`); 52 | }); 53 | 54 | if (process.env.APP_NAME) 55 | keepAlive(); 56 | } 57 | 58 | const cdn = 'https://cdn.lavalink.ga/v3.3.2.1/Lavalink.jar' 59 | download(cdn, './Lavalink.jar', startLavalink) 60 | 61 | 62 | function keepAlive() { 63 | console.log('Keeping alive.'); 64 | 65 | const fetch = require('node-fetch'); 66 | 67 | let count = 0; 68 | setInterval(() => 69 | fetch(`http://${process.env.APP_NAME}/`, { headers: { Authorization: process.env.PASS } }) 70 | .then(() => console.log(`[${++count}] Kept server alive.`)) 71 | .catch(() => console.log(`Failed to keep server alive.`)) 72 | , 1 * 60 * 1000); 73 | } 74 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # heroku-lavalink 2 | 3 | ![LavalinkOnHeroku](https://socialify.git.ci/IamTheRealSami/LavalinkOnHeroku/image?description=1&font=Source%20Code%20Pro&forks=1&issues=1&language=1&owner=1&pattern=Formal%20Invitation&pulls=1&stargazers=1&theme=Dark) 4 | 5 | Now with internal pinging. 6 | 7 | Easily deploy a lavalink server on heroku. 8 | This is a very elementary and barebones approach, but reliable nonetheless. 9 | This branch will automatically download the Lavalink.jar, but it may not be latest. 10 | 11 | Current Lavalink release: **v3.3.2.1** 12 | 13 | # DEPRECATION NOTICE 14 | 15 | I've officially stopped providing any updates to this as it was just made for fun. You're free to fork, make modification and run it on your own heroku client but tbh, why do you wanna do so? Make an account on DigitalOcean using my [link to get free $100 credit to use.](https://m.do.co/c/85f061dbe5c1) 16 | 17 | **Using Github Deploy:** 18 | 1. Create a fork of this repo 19 | 2. Navigate to your heroku project @dashboard.heroku.com 20 | 3. Navigate to your project *"Settings"*, click *"Reaveal Config Vars"*, and set a new var called *PASS* to what you want your lavalink password to be. 21 | 4. Navigate to the *"Deploy"* tab 22 | 5. Find/Click the *"Connect to GitHub"* section and login if needed 23 | 6. For the repo name, type *"heroku-lavalink"* and Click *"Search"* 24 | 7. Click *"Connect"* 25 | 8. Scroll down and find *"Manual Deploy"*, then switch the branch to auto and *"Deploy Branch"*. 26 | 27 | **Heroku CLI:** 28 | 1. Download files (Clone or download->Download ZIP). 29 | 2. Extract files into an empty directory. 30 | 3. Follow https://devcenter.heroku.com/articles/git. 31 | If heroku is unable to automatically configure buildpacks, go to your projects settings on the heroku website and add java and nodejs. 32 | 4. Go to your project settings->config vars on heroku and set a new var called PASS to what you want your lavalink password to be. 33 | 34 | **Easy Heroku Deploy Button** 35 | 36 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/IamTheRealSami/LavalinkOnHeroku/tree/auto) 37 | 38 | **Notes:** 39 | 1. After changing PASS you must redeploy or click the More menu and *restart all dynos*. 40 | 2. If heroku is unable to automatically configure buildpacks, go to your projects settings on the heroku website and add java and nodejs. 41 | --------------------------------------------------------------------------------