Skip to content

Commit

Permalink
Merge pull request #72 from BEEG3R/OptionalPortVariable
Browse files Browse the repository at this point in the history
Allow express server port to be set from environment variable
  • Loading branch information
m0ngr31 committed Oct 20, 2023
2 parents cccd055 + 19714a4 commit 08606cd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ RUN \
cd /app && \
npm ci

EXPOSE 8000

RUN chmod +x entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ The recommended way of running is to pull the image from [Docker Hub](https://hu
| PROXY_SEGMENTS | Proxy keyed `*.ts` files. | No | False |
| PUID | Current user ID. Use if you have permission issues. Needs to be combined with PGID. | No ||
| PGID | Current group ID. Use if you have permission issues. Needs to be combined with PUID. | No ||
| MAX_RESOLUTION | Max resolution to use. Valid options are `UHD/HDR`, `UHD/SDR`, `1080p`, `720p`, and `540p` (Some providers don't offer 4K or 1080p and will attempt to play the highest framerate available for selected resolution). | No | UHD/SDR |
| MAX_RESOLUTION | Max resolution to use. Valid options are `UHD/HDR`, `UHD/SDR`, `1080p`, `720p`, and `540p` (Some providers don't offer 4K or 1080p and will attempt to play the highest framerate available for selected resolution). | No | UHD/SDR ||
| PORT | Port the API will be served on. You can set this if it conflicts with another service in your environment. | No | 8000 |

### Available channel options

Expand Down
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {foxHandler} from './services/fox-handler';
import {mlbHandler} from './services/mlb-handler';
import {cleanEntries, removeChannelStatus} from './services/shared-helpers';
import {appStatus} from './services/app-status';
import {SERVER_PORT} from './services/port';

import {version} from './package.json';

Expand Down Expand Up @@ -199,7 +200,7 @@ process.on('SIGINT', shutDown);
await schedule();

console.log('=== Starting Server ===');
app.listen(8000, () => console.log('Server started on port 8000'));
app.listen(SERVER_PORT, () => console.log(`Server started on port ${SERVER_PORT}`));
})();

// Check for events every 4 hours and set the schedule
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

8 changes: 8 additions & 0 deletions services/port.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import _ from 'lodash';

let serverPort = _.toNumber(process.env.PORT);
if (_.isNaN(serverPort)) {
serverPort = 8000;
}

export const SERVER_PORT = serverPort;

0 comments on commit 08606cd

Please sign in to comment.