···606061611. Update `SERVICES` in `configure/operations/services.py` with your new service
62622. Run `mise run op-add-service`
6363+6464+### Foundry and SigNoz
6565+6666+This is experimental, so was installed manually.
6767+6868+First, foundry was installed using the instructions here https://github.com/SigNoz/foundry
6969+7070+I did have to do the following to get foundryctl to work and I followed the prerequesites here: https://github.com/SigNoz/foundry/tree/main/docs/examples/systemd/binary#prerequisites
7171+7272+I changed the storage option to sqlite instead of postgresql.
7373+7474+7575+# Secrets
7676+7777+`infra_do_space_json`:
7878+7979+1. Go to
+82
configure/operations/postgresql.py
···11+from pyinfra import host, state
22+from pyinfra.facts.server import LinuxName
33+from pyinfra.operations import apt, files, postgresql, python
44+55+if host.get_fact(LinuxName) != "Ubuntu":
66+ # Raises an exception mid-deploy
77+ python.raise_exception(
88+ name="Ensure we are Ubuntu",
99+ exception=NotImplementedError,
1010+ args=("`postgresql.py` only works on Ubuntu",),
1111+ )
1212+1313+1414+apt.packages(packages=["postgresql"], update=True, cache_time=3600)
1515+1616+# Example from pyinfra:
1717+1818+# # Setup a PostgreSQL role & database
1919+# #
2020+2121+# postgresql.role(
2222+# name="Create the PostgreSQL role",
2323+# role="pyinfra",
2424+# password="somepassword",
2525+# superuser=True,
2626+# login=True,
2727+# sudo_user="postgres",
2828+# )
2929+3030+# postgresql.database(
3131+# name="Create the pyinfra_stuff database",
3232+# database="pyinfra_stuff",
3333+# owner="pyinfra",
3434+# encoding="UTF8",
3535+# sudo_user="postgres",
3636+# )
3737+3838+3939+# # Upload & import a SQL file into the pyinfra_stuff database
4040+# #
4141+4242+# filename = "files/a_db.sql"
4343+# temp_filename = state.get_temp_filename(filename)
4444+4545+# files.put(
4646+# name="Upload the a_db.sql file",
4747+# src=filename,
4848+# dest=temp_filename,
4949+# )
5050+5151+# postgresql.load(
5252+# name="Import the uploaded a_db.sql file",
5353+# src=temp_filename,
5454+# database="pyinfra_stuff",
5555+# sudo_user="postgres",
5656+# )
5757+5858+5959+# # Now duplicate the pyinfra_stuff database -> pyinfra_stuff_copy
6060+# #
6161+6262+# postgresql.database(
6363+# name="Create the pyinfra_stuff_copy database",
6464+# database="pyinfra_stuff_copy",
6565+# sudo_user="postgres",
6666+# )
6767+6868+# dump_filename = state.get_temp_filename("psql_dump")
6969+7070+# postgresql.dump(
7171+# name="Dump the pyinfra_stuff database",
7272+# dest=dump_filename,
7373+# database="pyinfra_stuff",
7474+# sudo_user="postgres",
7575+# )
7676+7777+# postgresql.load(
7878+# name="Import the pyinfra_stuff dump into pyinfra_stuff_copy",
7979+# src=dump_filename,
8080+# database="pyinfra_stuff_copy",
8181+# sudo_user="postgres",
8282+# )
+4-1
configure/operations/release.py
···50505151 return bool(file_exists)
52525353+5354def service_definition_exists(conf: SystemdServiceConf) -> bool | None:
5455 from pyinfra.facts.files import File as FileFact
5556 from pyinfra import host
···5758 file_exists = host.get_fact(FileFact, str(conf.service_definition_path))
58595960 return bool(file_exists)
6161+60626163def service_running(conf: SystemdServiceConf) -> bool | None:
6264 from pyinfra.facts.systemd import SystemdStatus
···119121120122 systemd.service(service=conf.service_name, daemon_reload=True)
121123124124+122125def stop_service(conf: SystemdServiceConf):
123126 from pyinfra.operations import systemd
124127···153156 if not executable_exists(conf):
154157 install_executable(conf)
155158 needs_full_restart = True
156156-159159+157160 if needs_full_restart:
158161 start_service(conf)
159162 else: