Skip to content

Conversation

andrewheberle
Copy link
Contributor

This allows the currently hardcoded config dir and config files to be set on the command line.

The main driver behind this would be to have separate systemd unit files that refer to different configs.

eg

/lib/systemd/system/[email protected]

[Unit]
Description=Script Server
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/bin/python3 /opt/script-server/launcher.py --config-file %i.json

[Install]
WantedBy=multi-user.target

This allows different configs to be executed (maybe with different auth backends or ports or ssl config etc) as follows:

systemctl enable script-server@http
systemctl start script-server@http
systemctl enable script-server@https
systemctl start script-server@https

With matching config files:

conf/http.json

{
  "port": 80,
  "address": "0.0.0.0",
  "title": "Plain HTTP script server"
}

conf/https.json

{
  "port": 443,
  "address": "0.0.0.0",
  "title": "Secure HTTPS script server"
  "ssl": {
    "key_path": "conf/script-server.key",
    "cert_path": "conf/script-server.crt"
  }
}

@bugy
Copy link
Owner

bugy commented Oct 2, 2018

Hi @andrewheberle, thank you for the proposal, nice description and the implementation.
The code looks good, the only thing I would suggest is to allow absolute config-file paths. If it's absolute, we apply it as it is, otherwise get it relative to the config folder. Could you do it please, or I can accept your PR and fix myself.

Important note regarding the general approach of running multiple servers with the same working directory: script-server was not supposed to be used like this and there would be some conflicts. For example, log files get their "unique" id based on memory counter. In this case there would be id duplicates.

So I'll introduce a possibility to have different working directories for a script-server (based on config parameter), so all the operational files (logs, temp, etc.) will be stored there. By default configs will be read from this directory as well. What do you think?

@andrewheberle
Copy link
Contributor Author

Thanks for the feedback.

I'll update the PR to allow for absolute paths of the config file.

I did wonder about multiple instances sharing the same working directory and if there would be any conflicts, but to be honest, I was only introduced to script-server today at work, so I hadn't looked into those sort of "side effects" before firing off this PR :)

@bugy
Copy link
Owner

bugy commented Oct 3, 2018

Thank you!

@bugy bugy merged commit 16e0be1 into bugy:master Oct 3, 2018
@andrewheberle andrewheberle deleted the patch-1 branch May 22, 2019 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants